gpt4 book ai didi

java - 查询 AD 以获得无限结果

转载 作者:行者123 更新时间:2023-11-30 11:03:00 29 4
gpt4 key购买 nike

我正在使用下一个代码来获取 AD 中的所有用户

Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://grupoasisa.local:636");
env.put(Context.SECURITY_PROTOCOL, "ssl");
env.put(Context.SECURITY_PRINCIPAL, "DOMASISA\\"+USER_SERVICE);
env.put(Context.SECURITY_CREDENTIALS, PASSWORD_SERVICE);

try {
DirContext ctx = new InitialLdapContext(env, null);

SearchControls searchCtls = new SearchControls();

String returnedAtts[]={"sAMAccountName", "description", "mail"};

searchCtls.setReturningAttributes(returnedAtts);

//Specify the search scope
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
searchCtls.setTimeLimit(0);
searchCtls.setCountLimit(0);

//Specify the LDAP search filter
String searchFilter="(&(objectCategory=person)(objectClass=user))";
//Specify the Base for the search
String searchBase = "DC=grupoasisa,DC=local";

// Search for objects using the filter
NamingEnumeration<SearchResult> answer = ctx.search(searchBase, searchFilter, searchCtls);

//Loop through the search results
while (answer.hasMoreElements()) {
SearchResult searchResult = answer.next();
Attributes attrs = searchResult.getAttributes();
Attribute usuWin = attrs.get("sAMAccountName");
Attribute racf = attrs.get("description");
Attribute email = attrs.get("mail");
}
} catch (NamingException e) {
System.err.println("Error: "+e.getMessage());
} catch (Exception e) {
System.err.println("Error: "+e.getMessage());
}

虽然我指定搜索是无限的,但我只收到前 1000 条记录。怎么了?

提前致谢。

最佳答案

不可能,您必须对结果进行分页 (PaginationControl)。尝试 this回答。

关于java - 查询 AD 以获得无限结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30567983/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com