问题描述
可能的重复:
我可以得到超过 1000来自 Asp.Net 中 DirectorySearcher 的记录?
我正在使用 ADS 目录搜索器 findAll() 方法搜索现有登录名(如下面的代码所示).看起来 findall 方法只返回 1000 个条目,尽管条目多于此.我如何找到每次登录的所有()?
I am searching for existing logins using ADS Directory searcher findAll() method (as in following code). It appears the findall method returns only 1000 entries although there are more entries than that. How do I findAll() of every login ?
IList<string> adslist = new List<string>();
using (DirectoryEntry de = new DirectoryEntry("LDAP://armlink.com", null, null, AuthenticationTypes.Secure))
using (DirectorySearcher ds = new DirectorySearcher(de, "(objectclass=user)", new string[] { "samaccountname" }))
foreach (SearchResult sr in ds.FindAll())
{
string[] e = sr.Path.Split(new string[] { "LDAP://", "OU=", ",", "DC=", ".com", "/CN=" }, StringSplitOptions.RemoveEmptyEntries);
ResultPropertyCollection pc = sr.Properties;
adslist.Add(e[0] + "/" + pc["samaccountname"][0].ToString());
// Debug.WriteLine(adslist.Last());
}
推荐答案
这是由于服务器端限制造成的.来自 DirectorySearcher.SizeLimit 文档:
This is due to a server-side limit. From the DirectorySearcher.SizeLimit documentation:
对象的最大数量服务器在搜索中返回.这默认值为零,这意味着使用服务器确定的默认大小限制为 1000 个条目.
The maximum number of objects that the server returns in a search. The default value is zero, which means to use the server-determined default size limit of 1000 entries.
还有:
如果您将 SizeLimit 设置为大于服务器确定的默认值 1000条目,使用服务器确定的默认值.
If you set SizeLimit to a value that is larger than the server-determined default of 1000 entries, the server-determined default is used.
基本上,除非有一种方法可以更改服务器端默认值,否则您将被限制为 1000 个条目.指定 PageSize 可能会让您一次获取某个数字,total 大于 1000 ......不确定.
Basically from this, it looks like unless there's a way of changing the server-side default, you're going to be limited to 1000 entries. It's possible that specifying a PageSize will let you fetch a certain number at a time, with a total greater than 1000... not sure.
顺便说一句,您似乎还应该在 SearchResultCollection 周围有一个 using 指令:
By the way, it looks like you should also have a using directive around the SearchResultCollection:
using (SearchResultCollection results = ds.FindAll())
{
foreach (SearchResult sr in results)
{
...
}
}
这篇关于c# Active Directory 服务 findAll() 仅返回 1000 个条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)