Announcement Announcement Module
Collapse
No announcement yet.
Maximum search completion time limit using setTimeLimit Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 "javax.naming.directory.SearchControls" 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:

    JNDI:
    Code:
     SearchControls ctls = new SearchControls();
     ctls.setReturningAttributes (attrIDs);
     ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
     ctls.setCountLimit(10);
     ctls.setTimeLimit(1);
    
     NamingEnumeration answer = ctx.search(BASE_DN, filter, ctls);
    Spring LDAP:
    Code:
     SearchControls searchControls = new SearchControls();
      searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
    searchControls.setTimeLimit(1);
    
    return ldapTemplate.search("", equalsFilter.encode(), searchControls, 
    new PersonAttributeMapper());
    Where "ldapTemplate" has been defined as follows:
    Code:
    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
            <constructor-arg ref="contextSource" />
    </bean>
    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,

    Salitre

  • #2
    SearchControls.setTimeLimit works fine. You will get a TimeLimitExceededException from the LdapTemplate.search 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.

    Comment


    • #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?

      Comment

      Working...
      X