What login name to use for Spring LDAP authentication
<p>I created a local LDAP server and added the user "djiao" with password "123456
<a href="https://i.stack.imgur.com/NGqBa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NGqBa.png" alt="enter image description here"></a></p>

<p>Trying to implement authentication with Spring Security with Spring Boot. My webconfig class is as follows:</p>

<pre><code>@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
                .anyRequest()
                .authenticated()
                .and()
            .formLogin();
    }

    @Bean
    public ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
        ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider("", "ldap://localhost:10389");
        provider.setConvertSubErrorCodesToExceptions(true);
        provider.setConvertSubErrorCodesToExceptions(true);
        provider.setUseAuthenticationRequestCredentials(true);
        return provider;
    }

    @Bean
    public LoggerListener loggerListener() {
        return new LoggerListener();
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(activeDirectoryLdapAuthenticationProvider());
    }
</code></pre>

<p>However I can't seem to login from the login page.</p>

<ol>
<li><p>If I use djiao (cn) or djiao1 (uid), I will get 500.</p>

<p>[LDAP: error code 34 - Incorrect DN given : djiao1 (0x64 0x6A 0x69 0x61 0x6F 0x31 ) is invalid]; nested exception is javax.naming.InvalidNameException: [LDAP: error code 34 - Incorrect DN given : djiao1 (0x64 0x6A 0x69 0x61 0x6F 0x31 ) is invalid]</p></li>
<li><p>If I use dn "cn=djiao,ou=Users,dc=example,dc=com" as the username I will get "Bad credentials" error. And the password is simply 123456. </p></li>
</ol>

<p>What should the username for login? Or am I missing something in websecurityconfig class?</p>