I have this code to connect to Active Directory and get all the groups that exist, it works and returns all the groups in results :
DirectoryEntry dirEnt = new DirectoryEntry(); using (DirectorySearcher srch = new DirectorySearcher(dirEnt, '(objectClass=Group)')) { srch.PageSize = 1000; SearchResultCollection results = srch.FindAll(); }
I now want to return users of a specific group i.e. Administrators, how would I go about this?
I had tried changing (objectClass=Group) to (objectClass=Group)(cn=admin) but then it returns no results.
All the best
Here’s a reference about how to in Active Directory:
Howto: (Almost) Everything In Active Directory via C#