Announcement Announcement Module
No announcement yet.
Maximum search completion time limit using setTimeLimit Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Maximum search completion time limit using setTimeLimit

    Hi everyone,

    I need to set a maximum search completion time limit for my LDAP queries.

    According to the JNDI Javadoc, the method "setTimeLimit" in "" would do. However, I've set the least value ( 1 msec ) and there is no exception ( and I get the correct search result )

    I've tried with both JNDI API code and Spring LDAP:

     SearchControls ctls = new SearchControls();
     ctls.setReturningAttributes (attrIDs);
     NamingEnumeration answer =, filter, ctls);
    Spring LDAP:
     SearchControls searchControls = new SearchControls();
    return"", equalsFilter.encode(), searchControls, 
    new PersonAttributeMapper());
    Where "ldapTemplate" has been defined as follows:
    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
            <constructor-arg ref="contextSource" />
    I don't know what I may be doing wrong. I also have set a "com.sun.jndi.ldap.connect.timeout" ( value 240 ms ), but I don't think that this might be the error.

    Maybe I need to set the "search time limit" on org.springframework.ldap.core.LdapTemplate, but I can't see any related property on this class. And as far as I know, there is no environment or System property to set this paramater. So, it must be done through the SearchControls class.

    Thank you in advance,


  • #2
    SearchControls.setTimeLimit works fine. You will get a TimeLimitExceededException from the method after the specified time.

    You normally need to have plenty of data in your database in order to exceed even very small time limits.


    • #3
      Using spring-ldap-core 1.3.1 I'm having the same problem as the original poster. I have a timeout of 5000 ms and 200 entries and after 45 seconds I get a

      org.springframework.ldap.SizeLimitExceededExceptio n: [LDAP: error code 4 - Search operation hit size limit. Found 200 Entries (0 Aliases), 5331 Attributes, 6696 Values.]; nested exception is javax.naming.SizeLimitExceededException: [LDAP: error code 4 - Search operation hit size limit. Found 200 Entries (0 Aliases), 5331 Attributes, 6696 Values.]; remaining name '******'

      But The time limit of 5000 ms should have thrown the TimeLimitExceededException about 40 seconds erliear. My code looks almost like the original code above (I build the control in a helper method - that's the only difference).

      I find almost no documentation to the time limits - is there any but the source?