Monday, May 17, 2010

Active Directory - Enumerating Members of a Group

Was looking today how to enumerate the members of an AD Group - found an easy example here: http://msdn.microsoft.com/en-us/library/ms180906(VS.80).aspx
DirectoryEntry group = new DirectoryEntry("LDAP://CN=Sales,DC=Fabrikam,DC=COM");
object members = group.Invoke("Members", null);
foreach(object member in (IEnumerable)members)
{
DirectoryEntry x = new DirectoryEntry(member);
Console.WriteLine(x.Name);
}

No comments: