认为是建立在Active Directory用户以下属性:
Consider the following properties as set up in Active Directory for a user:
在我的WinForms应用程序,我想显示在显示名称谁当前登录和使用应用程序的用户的。我怎么会去获取这些信息?
In my winforms application I would like to show the Display Name of the user who is currently logged on and using the application. How would I go about retrieving this information?
既然你是在.NET 4中,你可以使用 System.DirectoryServices.AccountManagement
(S .DS.AM)命名空间。阅读所有关于它的:
Since you're on .NET 4, you can use the System.DirectoryServices.AccountManagement
(S.DS.AM) namespace. Read all about it here:
基本上,你可以定义域范围内,并很容易地找到在AD用户和/或组:
Basically, you can define a domain context and easily find users and/or groups in AD:
// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find currently logged in user
UserPrincipal user = UserPrincipal.Current;
string displayName = user.DisplayName;
新S.DS.AM使得它可以很容易地玩弄用户和组AD。
The new S.DS.AM makes it really easy to play around with users and groups in AD.