Possible duplicate:
How to get user groups in Active Directory? (C #, asp.net)
Is there a way to get the current user using the System.DirectoryServices.AccountManagement namespace? I used the following:
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)
But I want to get more information about the current user, for example the names of the groups to which they belong, in plain text, and wonders if this provides an AccountManagement namespace.
Using this, we simply return strings of numbers that I cannot understand:
For Each item As IdentityReference In wi.Groups Console.WriteLine(item.ToString()) Next
source share