Java Authentication with Spring LDAP Baeldung

I am trying to connect to AD from Spring LDAP Project

I have not found any method from DefaultSpringSecurityContextSource

to set CN for authentication.

public void init(AuthenticationManagerBuilder auth) throws Exception {
        DefaultSpringSecurityContextSource context = new DefaultSpringSecurityContextSource("ldaps://,DC=ldaps,DC=com");


I haven't found a method like contect.setUserCN()



source to share

1 answer

No need to install CN. You just need to specify the dispatcherDN and managerPass as shown below in the context. The security Ldap will then use the context to locate the user, which matches the criteria, retrieves its DN, and then tries to bind with the retrieved DN and the given pass.

This is our configuration and it works fine:

public class SecurityConfig extends WebSecurityConfigurerAdapter {

    private SecurityConfigProperties conf;

    public void configureGlobal(AuthenticationManagerBuilder authBuilder) throws Exception {



But after your example code, there context.setUserDN()

should be what you are looking for.



All Articles