Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

For some reason, on monday, code that was working the previous week suddendly started giving me the following error.

System.DirectoryServices.DirectoryServicesCOMException (0x800700EA): More data is available. Which happens when I try to do a FindAll against an Ad query

I made a small console application and was able to reproduce the error. What would cause this error to occur?

   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;
    }
like image 599
Lareau Avatar asked Oct 28 '25 06:10

Lareau


1 Answers

For the test example above, I commented out the sorting and it worked.

For my main application, I was still getting the error.

Looks like this post still applies with .net 4.0 for this error message.

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>
like image 176
Lareau Avatar answered Oct 29 '25 21:10

Lareau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!