enumerate Users in Activedirectory group

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

}
 
S

S. Justin Gengo

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
 
S

shiv

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
 
S

S. Justin Gengo

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top