title: How to convert LDAP AuthenticationManagerBuilder to AuthenticationManager
body: <p>I'm using the following LDAP configuration that makes use of <code>GlobalAuthenticationConfigurerAdapter</code>:</p>
  <pre><code>public static class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {
          @Override
          public void configure(AuthenticationManagerBuilder auth) throws Exception {
              for (String ldapUrl : ldapUrls) { //I have multiple LDAP servers that must be included
                  auth.ldapAuthentication()
                          .userSearchFilter(&quot;...&quot;)
                          .contextSource()
                          .url(ldapUrl + ldapBase)
                          .managerDn(ldapUsername)
                          .managerPassword(ldapPassword);
              }
          }
      }
  }
  </code></pre>
  <p>As per the following docs, there is a new way of providing LDAP authentication beans:</p>
  <p><a href="https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter#ldap-authentication" rel="nofollow noreferrer">https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter#ldap-authentication</a> &gt; LDAP Authentication</p>
  <pre><code>@Bean
  AuthenticationManager ldapAuthenticationManager(
          BaseLdapPathContextSource contextSource) {
      LdapBindAuthenticationManagerFactory factory = 
          new LdapBindAuthenticationManagerFactory(contextSource);
      factory.setUserDnPatterns(&quot;uid={0},ou=people&quot;);
      factory.setUserDetailsContextMapper(new PersonContextMapper());
      return factory.createAuthenticationManager();
  }
  </code></pre>
  <p>Question: how can I now transform my old configuration (that includes multiple LDAP urls) into the new beans?</p>
  <p>I mean, where can I get the <code>BaseLdapPathContextSource</code> from, and feed it with my ldap login credentials and base urls?</p>