简体   繁体   English

DirectorySearcher返回ERROR_MORE_DATA

[英]DirectorySearcher returns ERROR_MORE_DATA

I have developed an application that talks to the Directory Server and gets user information. 我已经开发了一个与Directory Server对话并获取用户信息的应用程序。

This application is a generic one and can talk to Active Directory or Any other Directory Services. 此应用程序是通用应用程序,可以与Active Directory或任何其他目录服务进行通信。

In one case where i use this application to read data from Radiant One VDS, the application fails with the ERROR_MORE_DATA . 在使用此应用程序从Radiant One VDS读取数据的一种情况下,该应用程序失败,并显示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 . 在上面的代码中, Searcher.FindAll()返回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 但是,本文讨论.NET 1.0,而我的应用程序与.NET 3.5一起运行

Can you anyone please help me here? 有人可以在这里帮助我吗? Is there any way to fix this without going for DirectoryServices.Protocols ? 有没有解决方法,而无需使用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 看到ERROR_MORE_DATA

You just need to specify the size of buffer. 您只需要指定缓冲区的大小即可。 see: specify the size of buffer in network call 请参阅: 指定网络调用中缓冲区的大小

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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