C# System.DirectoryServices.DirectoryServicesCOMException(0x800700EA):更多数据可用
出于某种原因,在周一,前一周运行的代码突然开始给我以下错误 System.DirectoryServices.DirectoryServicesCOMException(0x800700EA):更多数据可用。当我试图对广告查询进行FindAll时会发生这种情况 我制作了一个小型控制台应用程序,并能够重现错误。发生此错误的原因是什么C# System.DirectoryServices.DirectoryServicesCOMException(0x800700EA):更多数据可用,c#,active-directory,C#,Active Directory,出于某种原因,在周一,前一周运行的代码突然开始给我以下错误 System.DirectoryServices.DirectoryServicesCOMException(0x800700EA):更多数据可用。当我试图对广告查询进行FindAll时会发生这种情况 我制作了一个小型控制台应用程序,并能够重现错误。发生此错误的原因是什么 static void Main(string[] args) { var propToLoad = new StringCollect
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;
}
static void Main(字符串[]args)
{
var propToLoad=new StringCollection();
propToLoad.Add(ADProperty.distributedName);
DirectoryEntry de=新的DirectoryEntry();
de.Path=“MySearchROOT”;
DirectorySearcher ser=新的DirectorySearcher(de);
ser.Filter=“(&(&(&(&(dfaitUserType=PER)(objectCategory=person)(objectClass=user)(!dfaitObjectStatus=*)(!msExchHideFromAddressList=TRUE))(&(sAMAccountName=*)(dfaitOrgCode=*)(objectCategory=person)(objectClass=user)(!dfaitObjectStatus=*)(!msExchHideFromAddressList=TRUE))(!msExchHideFromAddressList=CBS)(employeeType=LES)(employeeType=CON)(employeeType=OGD)(employeeType=OTH)(employeeType=MIN))”;
//我们制作了常数来表示所有的Ad属性
ser.PROPERTYESTOLOAD.Add(ADProperty.LANSAME);
ser.PropertiesToLoad.Add(ADProperty.GivenName);
ser.PropertiesToLoad.Add(ADProperty.Mail);
ser.PROPERTYESTOLOAD.Add(ADProperty.DisplayName);
ser.PROPERTYESTOLOAD.Add(ADProperty.DfaitEdsId);
ser.PROPERTYESTOLOAD.Add(ADProperty.DISTITIGENDINGNAME);
ser.PROPERTYESTOLOAD.Add(ADProperty.MEMBEOF);
ser.PROPERTYESTOLOAD.Add(ADProperty.EmployeeType);
ser.PROPERTYESTOLOAD.Add(ADProperty.DEPARTY);
ser.PROPERTYESTOLOAD.Add(ADProperty.Company);
ser.PROPERTYESTOLOAD.Add(ADProperty.MSExchHideFromAddressList);
ser.PropertiesToLoad.Add(ADProperty.MailNickname);
ser.PropertiesToLoad.Add(ADProperty.Initials);
ser.PropertiesToLoad.Add(ADProperty.TelephoneNumber);
ser.PROPERTYESTOLOAD.ADP(ADProperty.FACSIMILETLEPHONENUMBER);
ser.PropertiesToLoad.Add(ADProperty.Mobile);
ser.PROPERTYESTOLOAD.Add(ADProperty.OTHERS电话);
ser.PROPERTYESTOLOAD.Add(ADProperty.Name);
ser.PROPERTYESTOLOAD.Add(ADProperty.Pager);
ser.PropertiesToLoad.Add(ADProperty.OtherMobile);
ser.PropertiesToLoad.Add(ADProperty.PhysicalDeliveryOfficeName);
ser.PROPERTYESTOLOAD.Add(ADProperty.TitleEng);
ser.PROPERTYESTOLOAD.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.singressing;
ser.PageSize=1000;
var returnValue=ser.FindAll();
WriteLine(“找到的记录总数={0}”,returnValue.Count);
Console.WriteLine();
foreach(返回值中的搜索结果res)
{
var found=GetMultiValue(res,ADProperty.differentiedName);
如果(找到!=null&found.Length>0)
{
Console.WriteLine(找到[0]);
}
}
}
公共静态字符串[]GetMultiValue(搜索结果,字符串字段名)
{
字符串[]返回值=null;
如果(结果!=null)
{
if(result.Properties.Contains(fieldName))
{
ResultPropertyValueCollection propertyValue=result.Properties[fieldName];
if(propertyValue!=null)
{
如果(propertyValue.Count>1)
{
string[]valueArray=新字符串[propertyValue.Count];
for(int i=0;i
对于上面的测试示例,我注释了排序,它成功了
对于我的主应用程序,我仍然得到错误
对于此错误消息,此帖子似乎仍适用于.net 4.0
一旦您的请求的结果太多,就会发生此错误。
虽然这似乎没有很好的文档记录,但findall可以处理的对象数量显然是有限制的,即使启用了分页功能 一种解决方法是切换到较低级别的访问,并使用System.DirectoryServices.Protocols代替分页。
您可以使用此处提供的代码: 另一个选项似乎是使用的变通方法并激活waitForPagedSearchData选项。但是,正如您在回答中所述,它显然并不能解决所有情况下的问题。但是,请确保您为实际使用的DirectoryServices版本设置了选项,如下所述:
今天遇到了这个问题,这解决了我的问题。投票!
<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>