我在我的.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();