How to get group membership with LDAP

  • Thread starter Thread starter Daniel Billingsley
  • Start date Start date
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?
 
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
 
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
 
Back
Top