I have configured LDAP connection pooling in a Spring boot application for LDAP searches (not LDAP binds). Here is my LDAP configuration:
@Bean
public ContextSource poolingLdapContextSource() {
PoolingContextSource poolingContextSource = new PoolingContextSource();
poolingContextSource.setDirContextValidator(new DefaultDirContextValidator());
poolingContextSource.setContextSource(ldapContextSource());
return poolingContextSource;
}
@Bean
public LdapContextSource ldapContextSource() {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrls(ldapUrls.toArray(new String[]{}));
contextSource.setUserDn(ldapUsername);
contextSource.setPassword(ldapPassword);
contextSource.setPooled(false);
return contextSource;
}
@Bean
public LdapTemplate ldapTemplate() throws Exception {
return new LdapTemplate(poolingLdapContextSource());
}
I have enabled debug logging in application.yml as follows:
org.springframework.ldap: debug
org.springframework.ldap.pool: debug
In the logs I see the following:
17-10-10 16:11:12:976 DEBUG oslcsAbstractContextSource - AuthenticationSource not set - using default implementation 2017-10-10 16:11:12:976 DEBUG oslcsAbstractContextSource - **Not using LDAP pooling** 2017-10-10 16:11:12:976 DEBUG oslcsAbstractContextSource - Trying provider Urls: ldap://xxx:389 ldap://yyy:389
Questions:
Might not help you now after a year or more but even with TRACE, no more logging comes out of org.springframework.ldap
or org.springframework.security
.
You could prove it to yourself in another couple of ways.
don't provide the non-pooled LdapContextSource
. Just provide it programmatically to PoolingContextSource.setContextSource()
run the server in debug and put a break-point in PoolingContextSource.getContext()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.