I am using spring-security-ldap-3.2.9, spring-ldap-core-1.3.2.
Intermittently we face ldap hangups where it takes more than 2 minutes. Implementing without spring framework has no issues.
Is this a known issue or some configuration that I am missing.
I experienced almost exactly this issue. The solution was to remove referral follow from the LdapContextSource. Fixed XML config is shown at the end of the answer.
Watching the code in VisualVM most of the execution time was spent in AbstractLdapNamingEnumeration.hasMore(). This led me to NamingEnumeration hasMoreElements method takes a lot of time when returning false for LDAP and I realized it was trying to follow referrals but I didn't need that. Turning it off got rid of the pauses.
<bean id="ldapContextSource"
class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="$ad{ldap.protocol}://$ad{ldap.server}:$ad{ldap.port}" />
<property name="base" value="${ldap.base}" />
<property name="userDn" value="$ldap{user}" />
<property name="password" value="$ldap{password}"/>
<!-- <property name="referral" value="follow" /> -->
<property name="baseEnvironmentProperties">
<map>
<entry key="java.naming.ldap.attributes.binary">
<value>objectSid</value>
</entry>
</map>
</property>
</bean>