471,317 Members | 1,505 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

AD searcher doesn't return all results.

I use DirectoryServices namespace to search AD.
I use "(&(objectcategory=person)(objectClass=user))" search string to
retrieve all users. However I noticed that not all users are returned.

There's a user nick named, say, yyyyy, and another named rrrrr.
rrrrr is returned by the query, yyyyy is not. Whn I use SmaAccountName
query for each, both are returned and objectclass and objectcategory
properties of the records are the same.

Why isn't yyyyy returned in the main result set (all users)?
Here's my code:

string strLdap = "LDAP://myserver";
System.DirectoryServices.DirectoryEntry entry = new
System.DirectoryServices.DirectoryEntry(strLdap,"s rv\\user","password");
System.DirectoryServices.DirectorySearcher searcher = new
System.DirectoryServices.DirectorySearcher(entry);

if (Request.QueryString["Nick"] != null)
{
searcher.Filter = String.Format("(SAMAccountName={0})",
Request.QueryString["Nick"]);
}
else
{
searcher.Filter = "(&(objectcategory=person)(objectClass=user))" ;
}
System.DirectoryServices.SearchResultCollection resultsCol =
searcher.FindAll();

for(int i=0; i<resultsCol.Count; i++)
{

if(resultsCol[i].Properties["samaccountname"]!=null)
{
..... do stuff ...................

Jan 23 '06 #1
0 962

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Chris Allen | last post: by
4 posts views Thread by Bob Bedford | last post: by
2 posts views Thread by little susane | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.