我正在使用我的.net核心项目中的novell.directory.ldap.netstandard查询我的活动目录。
它最多只能带回 1000 个用户,我知道这是因为服务器上的 PageSize 设置为 1000,我如何获取代码以带回所有活动目录用户? - 我正在使用异步搜索方法。
string ldapHost = "";
int ldapPort = ;
string loginDN = "";
string password = "";
string searchBase = "";
string searchFilter = "";
string[] attributes = new string[] { "givenName", "sn"};
LdapConnection ldapConn = new LdapConnection();
ldapConn.Connect(ldapHost, ldapPort);
ldapConn.Bind(loginDN, password);
LdapSearchQueue queue = ldapConn.Search(searchBase, LdapConnection.SCOPE_SUB, searchFilter, attributes, false, (LdapSearchQueue)null, (LdapSearchConstraints)null);
LdapMessage message;
int i = 1;
while ((message = queue.getResponse()) != null)
{
if (message is LdapSearchResult)
{
LdapEntry entry = ((LdapSearchResult)message).Entry;
LdapAttributeSet attributeSet = entry.getAttributeSet();
Console.WriteLine(i + " " + attributeSet.getAttribute("givenName")?.StringValue + " " + attributeSet.getAttribute("sn")?.StringValue);
i++;
}
}
ldapConn.Disconnect();
在 LDAP 术语中,您需要使用页面结果控件。
在C#中,这个问题似乎涵盖了它: https://stackoverflow.com/a/90668/7990687