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.
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.