Active directory users and associated groups

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
 
M

Marc Scheuner [MVP ADSI]

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
 
J

John

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
 

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