title: Setting timeout on ldap query for spring security
body: <p>I'm using spring security with LDAP authentication. My security configuration XML file can be <a href="https://github.com/cBioPortal/cbioportal/pull/102/files#diff-1f4c88247875f08f205de1897d72000cR425" rel="nofollow">found here</a>. My problem is that the query times out after some time. How can I set the timeout to a larger value?</p>
  
  <p>Here is the error log:</p>
  
  <pre><code>org.springframework.ldap.UncategorizedLdapException: Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: LDAP response read timed out, timeout used:-1ms.; remaining name 'OU=Struktur,
          at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:217)
          at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:318)
          at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:258)
          at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:605)
          at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:523)
          at org.springframework.security.ldap.SpringSecurityLdapTemplate.searchForSingleAttributeValues(SpringSecurityLdapTemplate.java:171)
          at org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator.getGroupMembershipRoles(DefaultLdapAuthoritiesPopulator.java:215)
          at org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator.getGrantedAuthorities(DefaultLdapAuthoritiesPopulator.java:185)
          at org.springframework.security.ldap.authentication.LdapAuthenticationProvider.loadUserAuthorities(LdapAuthenticationProvider.java:197)
          at org.springframework.security.ldap.authentication.AbstractLdapAuthenticationProvider.authenticate(AbstractLdapAuthenticationProvider.java:82)
          at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
          at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:177)
          at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:94)
          at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:211)
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
          at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
          at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
          at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
          at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
          at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
          at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
          at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
          at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
          at org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:436)
          at org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:177)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
          at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
          at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
          at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
          at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
          at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
          at java.lang.Thread.run(Thread.java:745)
  Caused by: javax.naming.NamingException: LDAP response read timed out, timeout used:-1ms.; remaining name 'OU=Struktur,DC=organization,DC=de'
          at com.sun.jndi.ldap.Connection.readReply(Connection.java:483)
          at com.sun.jndi.ldap.LdapClient.getSearchReply(LdapClient.java:639)
          at com.sun.jndi.ldap.LdapClient.search(LdapClient.java:562)
          at com.sun.jndi.ldap.LdapCtx.doSearch(LdapCtx.java:1985)
          at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1847)
          at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1772)
          at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:386)
          at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:356)
          at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:339)
          at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:267)
          at org.springframework.ldap.core.LdapTemplate$4.executeSearch(LdapTemplate.java:252)
          at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:292)
          ... 45 more
  </code></pre>