<分区>
Possible Duplicate:
How to get the groups of a user in Active Directory? (c#, asp.net)
有没有办法使用 System.DirectoryServices.AccountManagement
命名空间获取当前登录的用户?我一直在使用以下内容:
Dim wi As System.Security.Principal.WindowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent()
Dim fullName As String = wi.Name.ToString
Dim loggedOnUser = fullName.Substring(fullName.IndexOf("\") + 1)
Console.WriteLine("The currently logged on user is {0}", loggedOnUser)
但我想要有关当前用户的更多信息,例如他们所属的纯文本组名,并且想知道 AccountManagement
命名空间是否提供此信息。
使用它只会返回我无法理解的数字字符串:
For Each item As IdentityReference In wi.Groups
Console.WriteLine(item.ToString())
Next