I am trying to use LDAP authentication with spring sceurity. I followed the article https://spring.io/guides/gs/authenticating-ldap/ for implementation. I am getting error "[LDAP: error code 50 - Insufficient Access Rights]; nested exception is javax.naming.NoPermissionException: [LDAP: error code 50 - Insufficient Access Rights]; remaining name 'uid=pmerla,ou=people'". How can this issue be fixed? below is my code for configuration
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().fullyAuthenticated()
.and()
.formLogin();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource()
.url("ldaps://ldap.uchicago.edu/dc=uchicago,dc=edu")
.and()
.passwordCompare()
.passwordEncoder(new BCryptPasswordEncoder())
.passwordAttribute("userPassword");
}
}
I also tested if ldap connection is active from my terminal using below command
ldapsearch -H ldaps://ldap.uchicago.edu -D "uid=pmerla,ou=people,dc=uchicago,dc=edu" -W
and it is giving me correct response
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…