0
votes

i am new to concept of active directory, so to integrate active directory with ldap i am using spring boot framework i.e using spring security with ldap. So based on same reference from stackoverflow i am not able to managed authentication with active directory.

Below is my sample code :

@Configuration
@EnableGlobalAuthentication
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

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

@Bean
public ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
    ActiveDirectoryLdapAuthenticationProvider activeDirectoryLdapAuthenticationProvider = new ActiveDirectoryLdapAuthenticationProvider(
            "xyzabcd.org", "ldap://192.168.100.161:389/");

    return activeDirectoryLdapAuthenticationProvider;
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.ldapAuthentication().userDnPatterns("uid={0},ou=Users").contextSource(contextSource());
}

@Bean
public DefaultSpringSecurityContextSource contextSource() {
    return new DefaultSpringSecurityContextSource(Arrays.asList("ldap://192.168.100.161:389/"),
            "DC=xyzabcd.org,DC=org");
}

}

with this i am getting below error

Your login attempt was not successful, try again.

Reason: Bad credentials

so guys please help me out with this problem Thanks

Is that the complete error message? Sometimes there is an error code that you can lookup that will tell you exactly what it didn't like about the credentials. - Gabriel Luci
@Grabriel Luci thanks for your response ,yes i am getting this error only - Nikhil Sharma