How to get group membership with LDAP

D

Daniel Billingsley

I'm trying to write a simple program to document group memberships in my
Active Directory structure.

As I understand it, LDAP is the way to do this programatically from C#.

I can get everything documented, but when I get to a group I don't know how
to reach in and get the members. The members are not Children of the group
DirectoryEntry, so how do I discover them?
 
M

Marc Scheuner [MVP ADSI]

I can get everything documented, but when I get to a group I don't know how
to reach in and get the members. The members are not Children of the group
DirectoryEntry, so how do I discover them?

Read the "member" property:

DirectoryEntry deGroup = new
DirectoryEntry("LDAP://cn=YourGroup,dc=yourCompany,dc=com");

foreach(object oMember in deGroup.Properties["member"])
{
Console.WriteLine(oMember.ToString());
}

Marc
 
D

Daniel Billingsley

Thanks. That did it.

Marc Scheuner said:
I can get everything documented, but when I get to a group I don't know how
to reach in and get the members. The members are not Children of the group
DirectoryEntry, so how do I discover them?

Read the "member" property:

DirectoryEntry deGroup = new
DirectoryEntry("LDAP://cn=YourGroup,dc=yourCompany,dc=com");

foreach(object oMember in deGroup.Properties["member"])
{
Console.WriteLine(oMember.ToString());
}

Marc
 

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