title: Causes for instant Timelimit error when accessing AD via java
body: <p>I am trying to chase down a problem with CAS that is causing the following exception to be thrown:</p>
  
  <pre><code>javax.naming.TimeLimitExceededException: [LDAP: error code 3 - Timelimit Exceeded]; remaining name ''
          at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3097)
          at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2987)
          at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2794)
          at com.sun.jndi.ldap.LdapNamingEnumeration.getNextBatch(LdapNamingEnumeration.java:129)
          at com.sun.jndi.ldap.LdapNamingEnumeration.hasMoreImpl(LdapNamingEnumeration.java:198)
          at com.sun.jndi.ldap.LdapNamingEnumeration.hasMore(LdapNamingEnumeration.java:171)
          at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:295)
          at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:361)...
  </code></pre>
  
  <p>The error is returned virtually instantly.  The client side timeout is set to 10 seconds, but that isn't occuring as, based on looking through the com.sun.jndi.ldap code, it appears that the domain controller is returning a response with a status of 3, indicating a time limit exceeded.</p>
  
  <p>We are hitting an Active Directory global catalog, and our filter and base are pretty broad:   base = '', filter = (proxyAddresses=*:someone@somewhere.com)
  However, the query succeeds sometimes, but returns an immediate status code 3.</p>
  
  <p>Does anyone know what might be causing this kind of behavior?  Or perhaps how to go about determining what exactly is occurring?</p>