enumerate Users in Activedirectory group

  • Thread starter Thread starter shiv
  • Start date Start date
S

shiv

Hi all,

I am able to read groups in the domain but not able to
read the members within each group. can somebody help?

here goes the code

DirectoryEntry m_obDirEntry=new DirectoryEntry
("LDAP://mydomain");
SearchResultCollection results;
DirectorySearcher srch = new DirectorySearcher
(m_obDirEntry);
srch.Filter = "(objectClass=Group)";
results = srch.FindAll();

foreach (SearchResult src in results)
{

ActiveDs.IADsGroup grp=(ActiveDs.IADsGroup)
(src.GetDirectoryEntry().NativeObject);
Response.Write(grp.Name+"<br>");

// from here i want to read the names of the members in
this group

}
 
Shiv,

For any group you want to see the members of use "cn" (Common Name) for your
filter and one of the group names returned from your original query. Then
just repeat the query exactly as you've written the first one with the new
filter.

This will return all entries inside of the group.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
hi justin,

thanks for the reply. I tried to do that but failed to get
the results. here's what i did

after i get a ActiveDs.ISDSGroup,

I create one more directorySearcher giving the same
DirectoryEntry,
Filter it by filter=""(objectClass=Group)("+grp.Name+")"
where drp is ActiveDs.IsdsGroup.
and after looping through the results i get the same
results back. it seems the filter is not working. is the
filter string correct in my case?

thanks and regards
shiv
 
Shiv,

At the second level your filter should not contain group at all. Just
"cn=[Main Group Name Returned From First Pull]"

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
Back
Top