Re: Active directory: Get users associated with groups
From: Marc Scheuner [MVP ADSI] (m.scheuner_at_inova.SPAMBEGONE.ch)
Date: 03/15/05
- Next message: in: "I HATE STATICS"
- Previous message: Marc Scheuner [MVP ADSI]: "Re: User Listing from AD"
- In reply to: Mark: "Active directory: Get users associated with groups"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Mar 2005 08:25:51 +0100
>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??
Insepect the user's "memberOf" property
DirectoryEntry deUser = new DirectoryEntry("LDAP://......");
foreach(string sGroupName in deUser.Properties["memberOf"])
{
Console.WriteLine(sGroupName);
}
This is the easy way of doing it - it will *NOT* show you the user's
"primary group", nor any nested groups. For those you'd need to
inspect the user object's "tokenGroups" attribute (which is a
collection of SID's), and then resolve those SIDs to group names.
Check out microsoft.public.adsi.general - there have been several
posts on how to read the full group membership by means of
"tokenGroups".
HTH
Marc
================================================================
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch
- Next message: in: "I HATE STATICS"
- Previous message: Marc Scheuner [MVP ADSI]: "Re: User Listing from AD"
- In reply to: Mark: "Active directory: Get users associated with groups"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|