AD searcher doesn't return all results.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • realgeek@gmail.com

    AD searcher doesn't return all results.

    I use DirectoryServic es namespace to search AD.
    I use "(&(objectcateg ory=person)(obj ectClass=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.Director yServices.Direc toryEntry entry = new
    System.Director yServices.Direc toryEntry(strLd ap,"srv\\user", "password") ;
    System.Director yServices.Direc torySearcher searcher = new
    System.Director yServices.Direc torySearcher(en try);

    if (Request.QueryS tring["Nick"] != null)
    {
    searcher.Filter = String.Format(" (SAMAccountName ={0})",
    Request.QuerySt ring["Nick"]);
    }
    else
    {
    searcher.Filter = "(&(objectcateg ory=person)(obj ectClass=user)) ";
    }
    System.Director yServices.Searc hResultCollecti on resultsCol =
    searcher.FindAl l();

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

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

Working...