Windows groups from a domain

  • Thread starter Thread starter uiranejeb
  • Start date Start date
U

uiranejeb

How can I determine the windows groups from a domain?
How can I determine all the windows groups to which a user belongs to?
(WindowsPrincipal says if a user belongs to a specific group. I need a list
with all the groups).
Thanks!
 
You can use the System.DirectoryServices library to get the user:

DirectoryEntry objUser = new
DirectoryEntry("WinNT://domain/username,user");

you can also use LDAP if it is Win2K, but then you'll need to perform a
search in AD.

The returned directory entry object has a "groups" method that you can
invoke (for the WinNT provider - the LDAP provider has a memberOf property
instead).

Be aware that the groups method and the memberOf property only return the
groups that the user is a direct member of, and does not include nested
groups. For LDAP you'd need to get the tokenGroups property and use the SIDs
returned to get the groups.


Arild
 
Back
Top