![](/img/trans.png)
[英]DirectorySearcher issue (either sizelimit return objects or null values on objects?)
[英]DirectorySearcher doesn't respect the SizeLimit property if the SizeLimit is 256 or over
我正在使用PrincipalSearcher
和DirectorySearcher
筛选用户并指定要抓取的属性。 在2个不同的网络上进行测试。 一个网络有8K +记录,另一个网络有135K +。 在135K +网络上,它无法将记录保存到数据库。 因此,我想对少量记录进行测试,但是对于我尝试过的几百条记录,它不会失败。 所以我尝试将其增加到一千。 但是,当我这样做时,它给了我一切,而不是我要求的千元。
这是我的操作方式:
using (PrincipalSearcher searcher = new PrincipalSearcher(new UserPrincipal(context)))
{
DirectorySearcher directorySearcher = searcher.GetUnderlyingSearcher() as DirectorySearcher;
directorySearcher.Filter = "(&(objectSid=*)(sn=*)(givenName=*)(objectGuid=*))";
directorySearcher.PropertiesToLoad.Add("ObjectGUID");
directorySearcher.PropertiesToLoad.Add("objectSid");
directorySearcher.PropertiesToLoad.Add("GivenName");
directorySearcher.PropertiesToLoad.Add("sn");
directorySearcher.PropertiesToLoad.Add("mail");
directorySearcher.PropertiesToLoad.Add("telephoneNumber");
directorySearcher.PropertiesToLoad.Add("sAMAccountName");
directorySearcher.PropertiesToLoad.Add("distinguishedName");
directorySearcher.PropertiesToLoad.Add("title");
directorySearcher.PropertiesToLoad.Add("department");
directorySearcher.PropertiesToLoad.Add("company");
directorySearcher.PropertiesToLoad.Add("manager");
directorySearcher.PropertiesToLoad.Add("PhysicalDeliveryOfficeName");
directorySearcher.PropertiesToLoad.Add("countryCode");
directorySearcher.SizeLimit = 255;
请注意,此处的大小限制为255。如果我在256以下指定一个值,它将返回我指定的I记录数。 在小型网络上运行的快速示例:
如果我告诉它给我255条记录,它将给我255条记录。 但是,如果我告诉它给我256或更高的价格,它想给我所有人。
对这里发生的事情有什么想法吗?
问题是DirectorySearcher
对象上的PageSize
属性。 当将非默认值设置为SizeLimit
属性时,页面大小似乎受到限制。 我将PageSize
属性设置为4000,并且我在SizeLimit中输入的任何值都会提取该确切数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.