java Spring LDAP:错误代码 4 - 超出大小限制 - 将 countLimit 设置为 1 时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16734521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring LDAP: error code 4 - Sizelimit Exceeded - when setting countLimit to 1
提问by Danubian Sailor
Using Spring-LDAP 1.3.1 I was trying to read the content of an LDAP and I've got the following error:
使用 Spring-LDAP 1.3.1 我试图读取 LDAP 的内容,但出现以下错误:
LDAP: error code 4 - Sizelimit Exceeded
LDAP:错误代码 4 - 超出大小限制
After searching how to limit the result size, I've found that the class SearchControlsis responsible for it.
在搜索如何限制结果大小后,我发现该类SearchControls负责它。
So now my code looks like this:
所以现在我的代码如下所示:
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);
But still, the same error is thrown. So, it seems that the count limit parameter is ignored (I can't find the reference to getCountLimit()in Eclipse after loading dependency sources).
但是,仍然会抛出相同的错误。因此,似乎忽略了计数限制参数(getCountLimit()加载依赖源后在 Eclipse 中找不到引用)。
So my question is, how should I set the size limit for LDAP query using Spring-LDAP?
所以我的问题是,我应该如何使用 Spring-LDAP 设置 LDAP 查询的大小限制?
回答by Terry Gardner
The size-limit to which you refer is the "client-requested" size-limit. No matter what the client sets the value to, it cannot override the server's size-limit resource restrictions. Professional-quality servers can limit the number of entries returned in many ways, perhaps your client has run into one of the limits.
您所指的大小限制是“客户端请求的”大小限制。无论客户端将值设置为什么,它都无法覆盖服务器的大小限制资源限制。专业品质的服务器可以通过多种方式限制返回条目的数量,也许您的客户端遇到了限制之一。
see also
也可以看看
回答by Archie
If you set a size limit, the server will limit the number of responses to that value. However, if there were actually more responses that could have been returned, if/when you attempt to iterate past the limit you will get that exception.
如果您设置了大小限制,服务器将限制对该值的响应数量。但是,如果实际上有更多的响应可以返回,如果/当您尝试迭代超过限制时,您将收到该异常。
Quoting the Javadoc for NamingEnumeration:
In another example, if a search() method was invoked with a specified size limit of 'n'. If the answer consists of more than 'n' results, search() would first return a NamingEnumeration. When the n'th result has been returned by invoking next() on the NamingEnumeration, a SizeLimitExceedException would then thrown when hasMore() is invoked.
在另一个示例中,如果使用指定的“n”大小限制调用 search() 方法。如果答案包含多个“n”个结果,search() 将首先返回一个 NamingEnumeration。当通过对 NamingEnumeration 调用 next() 返回第 n 个结果时,然后在调用 hasMore() 时抛出 SizeLimitExceedException。
回答by alexey
1) You can change sizelimitparameter in /etc/openldap/slapd.conf on server size. More information you can find here http://www.ldapadministrator.com/forum/sizelimit-exceeded-problem-t14.html
1) 您可以根据服务器大小更改/etc/openldap/slapd.conf 中的sizelimit参数。您可以在此处找到更多信息http://www.ldapadministrator.com/forum/sizelimit-exceeded-problem-t14.html
2)Or you can limit your query like eq. here Limit SQL/LDAP Query to 901 Rows
2)或者你可以限制你的查询,比如 eq。此处将 SQL/LDAP 查询限制为 901 行

