title: Spring LDAP: error code 4 - Sizelimit Exceeded - when setting countLimit to 1
body: <p>Using Spring-LDAP 1.3.1 I was trying to read the content of an LDAP and I've got the following error:</p>
  
  <blockquote>
    <p>LDAP: error code 4 - Sizelimit Exceeded</p>
  </blockquote>
  
  <p>After searching how to limit the result size, I've found that the class <code>SearchControls</code> is responsible for it. </p>
  
  <p>So now my code looks like this:</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>But still, the same error is thrown. So, it seems that the count limit parameter is ignored (I can't find the reference to <code>getCountLimit()</code> in Eclipse after loading dependency sources). </p>
  
  <p>So my question is, how should I set the size limit for LDAP query using Spring-LDAP?</p>