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