c# - System.DirectoryServices.DirectoryServicesCOMException (0x800700EA) : More data is available

标签 c# active-directory

由于某种原因,在星期一,上周运行的代码突然开始出现以下错误。

System.DirectoryServices.DirectoryServicesCOMException (0x800700EA): 更多数据可用。当我尝试针对广告查询执行 FindAll 时会发生这种情况

我制作了一个小型控制台应用程序并能够重现该错误。什么会导致此错误发生?

   static void Main(string[] args)
    {
        var propToLoad = new StringCollection();
        propToLoad.Add(ADProperty.DistinguishedName);

         DirectoryEntry de = new DirectoryEntry();
        de.Path = "MySearchROOT";

        DirectorySearcher ser = new DirectorySearcher(de);
        ser.Filter = "(&(&(&(dfaitUserType=PER)(objectCategory=person)(objectClass=user)(!dfaitObjectStatus=*)(!msExchHideFromAddressLists=TRUE))(&(sAMAccountName=*)(dfaitOrgCode=*)(objectCategory=person)(objectClass=user)(!dfaitObjectStatus=*)(!msExchHideFromAddressLists=TRUE)))(|(employeeType=CBS)(employeeType=LES)(employeeType=CON)(employeeType=OGD)(employeeType=OTH)(employeeType=MIN)))";


// We made constants to represent all the Ad properties
            ser.PropertiesToLoad.Add(ADProperty.Surname);
            ser.PropertiesToLoad.Add(ADProperty.GivenName);
            ser.PropertiesToLoad.Add(ADProperty.Mail);
            ser.PropertiesToLoad.Add(ADProperty.DisplayName);
            ser.PropertiesToLoad.Add(ADProperty.DfaitEdsId);
            ser.PropertiesToLoad.Add(ADProperty.DistinguishedName);
            ser.PropertiesToLoad.Add(ADProperty.MemberOf);
            ser.PropertiesToLoad.Add(ADProperty.EmployeeType);
            ser.PropertiesToLoad.Add(ADProperty.Department);
            ser.PropertiesToLoad.Add(ADProperty.Company);
            ser.PropertiesToLoad.Add(ADProperty.MSExchHideFromAddressLists);
            ser.PropertiesToLoad.Add(ADProperty.MailNickname);
            ser.PropertiesToLoad.Add(ADProperty.Initials);
            ser.PropertiesToLoad.Add(ADProperty.TelephoneNumber);
            ser.PropertiesToLoad.Add(ADProperty.FacsimileTelephoneNumber);
            ser.PropertiesToLoad.Add(ADProperty.Mobile);
            ser.PropertiesToLoad.Add(ADProperty.OtherTelephone);
            ser.PropertiesToLoad.Add(ADProperty.Name);
            ser.PropertiesToLoad.Add(ADProperty.Pager);
            ser.PropertiesToLoad.Add(ADProperty.OtherMobile);
            ser.PropertiesToLoad.Add(ADProperty.PhysicalDeliveryOfficeName);
            ser.PropertiesToLoad.Add(ADProperty.TitleEng);
            ser.PropertiesToLoad.Add(ADProperty.TitleFre);
            ser.PropertiesToLoad.Add(ADProperty.OtherHomePhone);
            ser.PropertiesToLoad.Add(ADProperty.TelephoneAssistant);
            ser.PropertiesToLoad.Add(ADProperty.Mail);
        ser.Sort.PropertyName = ADProperty.DfaitEdsId;
        ser.Sort.Direction = SortDirection.Ascending;
        ser.PageSize = 1000;

        var returnValue = ser.FindAll();

        Console.WriteLine("Total Records found = {0}", returnValue.Count);
        Console.WriteLine();

        foreach (SearchResult res in returnValue)
        {
            var found = GetMultiValue(res, ADProperty.DistinguishedName);
            if (found != null & found.Length > 0)
            {
                Console.WriteLine(found[0]);
            }
        }

    }

            public static string[] GetMultiValue(SearchResult result, string fieldName)
    {
        string[] returnValue = null;

        if (result != null)
        {
            if (result.Properties.Contains(fieldName))
            {
                ResultPropertyValueCollection propertyValue = result.Properties[fieldName];
                if (propertyValue != null)
                {
                    if (propertyValue.Count > 1)
                    {
                        string[] valueArray = new string[propertyValue.Count];
                        for (int i = 0; i < propertyValue.Count; i++)
                        {
                            string valStr = propertyValue[i].ToString();
                            valueArray[i] = valStr;
                        }

                        returnValue = valueArray;
                    }
                    else if (propertyValue.Count == 1)
                    {
                        string[] tempString = new string[] { propertyValue[0].ToString() };
                        returnValue = tempString;
                    }
                    else
                    {
                        string[] tempString = new string[] { };
                        returnValue = tempString;
                    }
                }
            }
        }

        return returnValue;
    }

最佳答案

对于上面的测试示例,我注释掉了排序并且它有效。

对于我的主应用程序,我仍然遇到错误。

对于此错误消息,这篇文章似乎仍然适用于 .net 4.0。

http://blogs.dirteam.com/blogs/tomek/archive/2006/11/09/More-data-is-available-exception-when-searching-with-S.DS.aspx

  <configSections>
    <section name="system.directoryservices" type="System.DirectoryServices.SearchWaitHandler, System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </configSections>

  <system.directoryservices>
    <DirectorySearcher waitForPagedSearchData="true" />
  </system.directoryservices>

关于c# - System.DirectoryServices.DirectoryServicesCOMException (0x800700EA) : More data is available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25268074/

相关文章:

c# - 如何匹配另一个列表中列表元素的子字符串?

powershell - 从 powershell 中的字符串中删除数字

.net - 无法批量加载,因为无法打开文件 “"。操作系统错误代码5(访问被拒绝。)

linux - 程序在针对 Active Directory 进行身份验证时接收 PAM_PERM_DENIED (7),而 ssh 有效

java - 带有错误 Active Directory Ldap 凭据的 session /Redis 序列化错误的 Spring Boot

c# - 获取数组中除少数之外的父级及其子级的所有 Material

javascript - 如何使用 jquerycropit 插件最小化请求的图像?

c# - EF 4 : The specified type member '*' is not supported in LINQ to Entities

C# SAP .net 连接器未返回与 SAP GUI 中所示相同的数据

powershell - 如何获取对象类型/标识符?