Windows groups from a domain

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!
 
A

Arild Bakken

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top