I'm trying to get list of a domain group members. I've found MSDN article Enumerating Users in a Group (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sds/sds/enumerating_users_in_a_group.asp). Code Example from the article: C#] DirectoryEntry
group = new DirectoryEntry("LDAP://CN=Sales,DC=Fabrikam,DC=COM"); foreach(object dn in group.Properties["member"] ) { Console.WriteLine(dn); } So I've changed this code pattern: DirectoryEntry group = new DirectoryEntry("LDAP://CN=Wanted_Group,dc=concord,dc=com");
foreach(object dn in group.Properties["member"] ) { Console.WriteLine(dn); } But I get "There is no such object on the server" error I've also tried to insert domain-controller name with the same result: DirectoryEntry group = new DirectoryEntry("LDAP://MyDomainController/CN=Wanted_Group,dc=concord,dc=com");
foreach(object dn in group.Properties["member"] ) { Console.WriteLine(dn); } I'm just learning Active Directory and c# and I believe that I could have written wrong directory path... There is a screenshot of full user's directory path: http://www.celer.spb.ru/lj/ad/full_path.gif
Unfortunately, the screenshot you have shown does not help me with your group path because it is of a user object and not the group that you want to inspect. In general, you need to make sure you have it pointed to the correct container for your group. What
you have written above says that the group you want to look at is located directly under the domain (which I kinda doubt). You would need to specify the container where the group was located as well: LDAP://CN=Wanted_Group,OU=Container,OU=Parent Container,DC=concord,DC=com
That is just to give you an idea. Just start at the object, and work backwards from left to right (i.e. start with the object (deepest), then its parent until you hit the domain (shallowest)).
relec
Member
10 Points
2 Posts
Enumerate Users in a Group
Nov 02, 2004 11:50 AM|LINK
dunnry
Star
9098 Points
1806 Posts
Re: Enumerate Users in a Group
Nov 06, 2004 09:22 PM|LINK
Weblog
The Book
LDAP Programming Help