繁体   English   中英

如何验证Spring LDAP连接池配置?

[英]How to verify Spring LDAP connection pooling configuration?

我已经在Spring Boot应用程序中为LDAP搜索(不是LDAP绑定)配置了LDAP连接池。 这是我的LDAP配置:

@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());
}

我已在application.yml中启用调试日志记录,如下所示:

org.springframework.ldap:调试

org.springframework.ldap.pool:调试

在日志中,我看到以下内容:

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

问题:

  1. 为什么日志显示“不使用LDAP池”?
  2. 如何获取有关池的更详细的日志记录,如何更深入地了解何时Spring打开新连接,存在多少活动连接等?

一年或更长时间后,现在可能无法为您提供帮助,但是即使有了TRACE, org.springframework.ldaporg.springframework.security不再提供日志记录。

您可以通过另外两种方式向自己证明。

  • 不提供非池化的LdapContextSource 只需以编程方式将PoolingContextSource.setContextSource()提供给PoolingContextSource.setContextSource()

  • 在调试中运行服务器,并在PoolingContextSource.getContext()放置一个断点。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM