[英]How to get more than 1000 results from ActiveDirectory?
我遇到了一个问题。 Linux 不支持 NetCor App System.DirectoryServices 的标准包。 决定转移到 Novell.Directory.Ldap.NETStandard。
在 AD 中,有 1000 个搜索结果的限制。 如何使用 Novell.Directory.Ldap.NETStandard 在客户端上返回 1000 多个结果?
这是我的代码。 它只返回 1000 条记录。
LdapSearchQueue queue = connection.Search("<this my base entry>",
LdapConnection.SCOPE_SUB,
"<this my filter>",
attr,
false,
(LdapSearchQueue)null,
new LdapSearchConstraints { MaxResults = 0 });
LdapMessage message;
while ((message = queue.getResponse()) != null)
{
if (message is LdapSearchResult)
{
LdapEntry entry = ((LdapSearchResult)message).Entry;
LdapAttributeSet attributeSet = entry.getAttributeSet();
var atr = attributeSet.getAttribute("sAMAccountName");
list.Add(atr.StringValue);
}
}
我发现以下解决方案
所有用户都在文件夹中。 每个文件夹中的用户数不超过1000。 该文件夹与用户是同一对象,但具有另一个objectType。
第一。 获取用户的所有文件夹的列表。 如果在任何文件夹中也有超过1000个文件夹,则对于此文件夹,必须将文件夹列表获取到以下级别(LdapConnection.SCOPE_ONE)。
第二。 转到找到的每个文件夹并收集其中的所有用户。
使用这种方法,每次迭代的搜索结果数不会超过1000。如果仍然存在这种情况,即在一个文件夹中有1000个以上的用户,那么您就有了问题。
一次不能退回超过 1000 件。 你需要组织循环。 使用 LdapControl 类 (Novell.Directory.Ldap.NETStandard.dll)。 这是作者的 Metacube 存储库,其中包含一个很好的项目工作示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.