I also ran into this problem and found some answers pointing to an environment variable com.sun.jndi.ldap.connect.timeout, but couldn't find how to add Spring Security with Java configuration in Spring.
, :
@Autowired
private DefaultSpringSecurityContextSource context;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
authenticationManagerBuilder
.ldapAuthentication()
.userSearchFilter(LDAP_USER_SEARCH_FILTER)
.contextSource(context);
}
, ( confiuration, ), , timeout:
@Bean
public DefaultSpringSecurityContextSource createContext() {
DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(LDAP_SERVER);
contextSource.setUserDn(LDAP_MANAGER_DN);
contextSource.setPassword(LDAP_MANAGER_PASSWORD);
Map<String, Object> environment = new HashMap<>();
environment.put("com.sun.jndi.ldap.connect.timeout", LDAP_TIMEOUT);
contextSource.setBaseEnvironmentProperties(environment);
return contextSource;
}
, LDAP_ - .