我要如何找到在C#Web应用程序用户的Active Directory显示名称? [英] How do I find a user's Active Directory display name in a C# web application?
本文介绍了我要如何找到在C#Web应用程序用户的Active Directory显示名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在写一个Web应用程序,它使用Windows身份验证,我可以使用类似愉快地获取用户的登录名:
I'm writing a web application which uses windows authentication and I can happily get the user's login name using something like:
string login = User.Identity.Name.ToString();
但我并不需要他们的登录名我希望自己的显示名称。我一直在敲打我的头一两个小时了......
But I don't need their login name I want their DisplayName. I've been banging my head for a couple hours now...
我可以通过一个Web应用程序访问我的组织的AD?
Can I access my organisation's AD via a web application?
推荐答案
这个怎么样:
private static string GetFullName()
{
try
{
DirectoryEntry de = new DirectoryEntry("WinNT://" + Environment.UserDomainName + "/" + Environment.UserName);
return de.Properties["fullName"].Value.ToString();
}
catch { return null; }
}
这篇关于我要如何找到在C#Web应用程序用户的Active Directory显示名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文