title: How can PoolingContextSource be used with ldap BindAuthenticator for connection pooling
body: <p>How can PoolingContextSource be used with ldap BindAuthenticator for connection pooling</p>
  <pre><code>@Bean
  public AuthenticationProvider ldapAuthenticationProvider() throws Exception {
      DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(ldapUrl);
      contextSource.setUserDn(ldapSecurityPrincipal);
      contextSource.setPassword(ldapPrincipalPassword);
      contextSource.setReferral(&quot;follow&quot;);
      contextSource.afterPropertiesSet();
      
       PoolingContextSource poolingContextSource = new PoolingContextSource();
          poolingContextSource.setDirContextValidator(new DefaultDirContextValidator());
          poolingContextSource.setContextSource(contextSource);
          poolingContextSource.setTestOnBorrow(true);
          poolingContextSource.setTestWhileIdle(true);
          
      BindAuthenticator bindAuthenticator = new BindAuthenticator((BaseLdapPathContextSource) poolingContextSource);
      FilterBasedLdapUserSearch ldapUserSearch = new FilterBasedLdapUserSearch(searchBase, searchAttribute,
              contextSource);
      bindAuthenticator.setUserSearch(ldapUserSearch);
      LdapAuthenticationProvider ldapAuthenticationProvider = new LdapAuthenticationProvider(bindAuthenticator);
      return ldapAuthenticationProvider;
  }
  </code></pre>
  <p>doesnt work. Springboot app itself doesnt start. Can someone help with right configuration?</p>