78lro
78lro

Reputation: 1790

Reading ldap group member from c#

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

Upvotes: 2

Views: 8278

Answers (1)

Turnkey
Turnkey

Reputation: 9406

Here's a reference about how to in Active Directory:

Howto: (Almost) Everything In Active Directory via C#

Upvotes: 3

Related Questions