Spring LDAP: error code 4 - Sizelimit Exceeded - when setting countLimit to 1

Using Spring -LDAP 1.3.1 I tried to read the contents of LDAP and I got the following error:

LDAP: Error Code 4 - Sizelimit Exceeded

After searching for how to limit the size of the result, I found that the SearchControls class is responsible for it.

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 an error occurs. Thus, it seems that the counter restriction parameter is ignored (I cannot find the link to getCountLimit() in Eclipse after loading the sources of the dependency).

So my question is: how do I set a size limit for an LDAP request using Spring-LDAP?

+4
source share
3 answers

The size limit you are referring to is the size limit of the client. No matter which client sets the value, it cannot override resource limits to limit server size. Professional-quality servers can limit the number of records returned in various ways, perhaps your client has completed one of the restrictions.

see also

+1
source

If you set a size limit, the server will limit the number of responses to this value. However, if there really were more answers that could be returned if / when you try to go over the limit, you will get this exception.

Javadoc quote for NamingEnumeration :

In another example, if the search () method was called with the specified size limit of 'n'. If the answer consists of more than "n" results, search () will first return NamingEnumeration. When the nth result was returned by calling next () in NamingEnumeration, a SizeLimitExceedException is then thrown when the hasMore () method is called.

0
source

1) You can change the sizelimit parameter in the /etc/openldap/slapd.conf file to the server size. You will find more information here http://www.ldapadministrator.com/forum/sizelimit-exceeded-problem-t14.html

2) Or you can limit your request, for example, eq. here Limit SQL / LDAP query to 901 rows

0
source

Source: https://habr.com/ru/post/1482554/


All Articles