title: How to authenticate a user from LDAP based on mail and by uid with spring Security?
body: <p>I want a user to be able to login both by his uid and by mail ? How to achieve this using my spring Security configuration ?</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
                  .authorizeRequests()
                  .anyRequest().fullyAuthenticated()
                  .and()
                  .formLogin().passwordParameter("password");
      }
  
      @Configuration
      protected static class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {
  
          @Autowired
          LdapContextSource contextSource;
  
          @Override
          public void init(AuthenticationManagerBuilder auth) throws Exception {
              auth
                      .ldapAuthentication()
                      .userDnPatterns("uid={0}")
                      .contextSource(contextSource);
          }
      }
  }
  </code></pre>
  
  <p>At userDnPatterns can I specify another attribute along with uid? Or authentication with uid is standard ?</p>