Active directory users and associated groups

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi, can anyone please tell me (Given a group name) how I can retrieve just
those users associated with that group using Active Directory using LDAP??

I am using the code below with not much luck

Code:
DirectoryEntry entry = new DirectoryEntry("LDAP://" +
Domain,"LoginUser","Password");
DirectorySearcher Dsearch = new DirectorySearcher(entry);
Dsearch.Filter = "objectCategory =All users"; // All users is a group in AD

TIA
Mark
 
Hi, can anyone please tell me (Given a group name) how I can retrieve just
those users associated with that group using Active Directory using LDAP??

You mean retrieve all the users that are MEMBER of that group, right?

Basically, you need to bind to the group, and then insepect the
"member" property

DirectoryEntry deGroup = new DirectoryEntry("LDAP://......");

foreach(string sUserName in deGroup.Properties["member"])
{
Console.WriteLine(sUserName);
}

HTH
Marc

================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
 
Thanks Marc, I'll give that a try
Regards
Marc Scheuner said:
Hi, can anyone please tell me (Given a group name) how I can retrieve just
those users associated with that group using Active Directory using
LDAP??

You mean retrieve all the users that are MEMBER of that group, right?

Basically, you need to bind to the group, and then insepect the
"member" property

DirectoryEntry deGroup = new DirectoryEntry("LDAP://......");

foreach(string sUserName in deGroup.Properties["member"])
{
Console.WriteLine(sUserName);
}

HTH
Marc

================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
 
Back
Top