c# LDAP Nested Group user List

V

Vikram

Hi, Can any give me an example which collects all the users of a given
group.
Im on Win2000 domain, using c#.

Currently my code below gives me only users directly in the group and
not in nested group.


DirectorySearcher searcher = new DirectorySearcher();
DirectoryEntry ContextEntry = new
DirectoryEntry("LDAP://machine/DC=machine,DC=local"
searcher.SearchRoot = ContextEntry;
foreach(System.DirectoryServices.SearchResult resEnt in
searcher.FindAll())
{
ResultPropertyCollection resultPropCollection = resEnt.Properties;

if(null != resultPropCollection["member"])
{
foreach( object MemberCollection in resultPropCollection["member"])
{
DirectoryEntry gpMemberEntry = new DirectoryEntry("LDAP://machine/"
+ MemberCollection);
System.DirectoryServices.PropertyCollection userProps =
gpMemberEntry.Properties;
object obVal = userProps["cn"].Value;
if (null != obVal)
{
groupMemebers.Add(obVal.ToString());
}
}
}
}





Thanks for your reply.
 

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