Java Spring LDAP:将countLimit设置为1时,错误代码4-超出了Sizelimit
使用SpringLDAP 1.3.1时,我试图读取LDAP的内容,但出现以下错误: LDAP:错误代码4-超出了Sizelimit 在搜索如何限制结果大小后,我发现类Java Spring LDAP:将countLimit设置为1时,错误代码4-超出了Sizelimit,java,ldap,spring-ldap,Java,Ldap,Spring Ldap,使用SpringLDAP 1.3.1时,我试图读取LDAP的内容,但出现以下错误: LDAP:错误代码4-超出了Sizelimit 在搜索如何限制结果大小后,我发现类SearchControls对此负责 现在我的代码如下所示: SearchControls controls = new SearchControls(); controls.setCountLimit(1); ContextMapper mapper = new ContextMapper() { public Obje
SearchControls
对此负责
现在我的代码如下所示:
SearchControls controls = new SearchControls();
controls.setCountLimit(1);
ContextMapper mapper = new ContextMapper() {
public Object mapFromContext(Object ctx) {
DirContextAdapter adapter = (DirContextAdapter) ctx;
Attributes attrs = adapter.getAttributes();
try {
return attrs.get("cn").get();
} catch (NamingException e) {
e.printStackTrace();
return null;
}
}
};
return ldapTemplate.search("OU=system,DC=de", "(objectclass=person)", controls, mapper);
但仍然会抛出相同的错误。因此,似乎忽略了count limit参数(在加载依赖项源之后,我在Eclipse中找不到对getCountLimit()
的引用)
所以我的问题是,我应该如何使用SpringLDAP设置LDAP查询的大小限制?您提到的大小限制是“客户端请求的”大小限制。无论客户机将该值设置为什么,它都无法覆盖服务器的大小限制资源限制。专业质量的服务器可以通过多种方式限制返回的条目数量,也许您的客户机遇到了其中一个限制 另见
2) 或者您可以像等式一样限制您的查询。这里我肯定LDAP服务器上有限制,但是如何使用Spring LDAP和/或Java中LDAP的查询语法限制查询大小?