现在LDAP有个目录存有超过500个用户的信息,我设置了setCountLimit(501);也只能读取500个用户,怎么办啊,大家遇到过吗?
private static DirContext ldapConnection() throws Exception {
Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, SUN_JNDI_PROVIDER);
env.put(Context.PROVIDER_URL, "ldap://10.203.2.164:389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "uid=username,cn=users,dc=tam,dc=sgmam,dc=com");
env.put(Context.SECURITY_CREDENTIALS, "password");
DirContext ctx = null;
try {
ctx = new InitialDirContext(env);
} catch (NamingException e) {
e.printStackTrace();
throw new Exception(e);
}
return ctx;
}private static void ldapSearch(DirContext ctx) throws NamingException {
SearchControls search = new SearchControls();
search.setSearchScope(SearchControls.SUBTREE_SCOPE);
String attrList[] = {"uid", "givenname", "ou", "mail", "departmentnumber", "title", "sn", "employeenumber"};
search.setReturningAttributes(attrList);
search.setDerefLinkFlag(true);
search.setReturningObjFlag(true);
String searchFilter = "(&(objectClass=*))";
search.setCountLimit(501);
NamingEnumeration results = ctx.search("cn=employees,dc=test,dc=tam,dc=sgmam,dc=com",searchFilter,search);
List list = getEmpList(results); System.out.println(list.size());
}
private static DirContext ldapConnection() throws Exception {
Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, SUN_JNDI_PROVIDER);
env.put(Context.PROVIDER_URL, "ldap://10.203.2.164:389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "uid=username,cn=users,dc=tam,dc=sgmam,dc=com");
env.put(Context.SECURITY_CREDENTIALS, "password");
DirContext ctx = null;
try {
ctx = new InitialDirContext(env);
} catch (NamingException e) {
e.printStackTrace();
throw new Exception(e);
}
return ctx;
}private static void ldapSearch(DirContext ctx) throws NamingException {
SearchControls search = new SearchControls();
search.setSearchScope(SearchControls.SUBTREE_SCOPE);
String attrList[] = {"uid", "givenname", "ou", "mail", "departmentnumber", "title", "sn", "employeenumber"};
search.setReturningAttributes(attrList);
search.setDerefLinkFlag(true);
search.setReturningObjFlag(true);
String searchFilter = "(&(objectClass=*))";
search.setCountLimit(501);
NamingEnumeration results = ctx.search("cn=employees,dc=test,dc=tam,dc=sgmam,dc=com",searchFilter,search);
List list = getEmpList(results); System.out.println(list.size());
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货