简体   繁体   中英

DirectorySearcher returns ERROR_MORE_DATA

I have developed an application that talks to the Directory Server and gets user information.

This application is a generic one and can talk to Active Directory or Any other Directory Services.

In one case where i use this application to read data from Radiant One VDS, the application fails with the ERROR_MORE_DATA . Following is the code that returns this error:

 try
{
  using (DirectoryEntry de = new DirectoryEntry("LDAP://" + server + "/" + basedn, username, pwd,AuthenticationTypes.None))
  {
    using (DirectorySearcher Searcher = new DirectorySearcher(de))
    {
      Searcher.Filter = "(&(objectClass=user))";
      Searcher.ReferralChasing = ReferralChasingOption.All;
      Searcher.PropertiesToLoad.Add("cn");
      Searcher.PropertiesToLoad.Add("memberof");
      Searcher.PageSize = 1000;

      using (SearchResultCollection allUsers = Searcher.FindAll())
      {                            
        foreach (SearchResult user in allGroups)
        {
          .
          .
          .
          .
        }
      }
    }
  }
}
catch(System.Exception ex)
{
}

In the above code, Searcher.FindAll() returns ERROR_MORE_DATA . When i searched i found the this article.

But, this article talks about .NET 1.0 and my application runs with .NET 3.5

Can you anyone please help me here? Is there any way to fix this without going for DirectoryServices.Protocols ?

Generally, this issue comes in the following situation:-

If one or more entries are found in Network and the buffer size is not enough to hold it. see ERROR_MORE_DATA

You just need to specify the size of buffer. see: specify the size of buffer in network call

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM