我在使用凭据登录ldap服务器时收到错误。
我的securityconfig类
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest()
.fullyAuthenticated()
.and()
.formLogin();
}
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.userSearchFilter("(employeeID={0})")
.userSearchBase("DC=xxx,DC=xxx")
.contextSource()
.url("ldap://localhost:389")
.managerDn("sxxx")
.managerPassword("xxx")
.and()
.passwordCompare()
.passwordEncoder(new LdapShaPasswordEncoder())
.passwordAttribute("userPassword");
}
@Bean
public DefaultSpringSecurityContextSource contextSource() {
return new DefaultSpringSecurityContextSource(Arrays.asList("ldap://localhost:389"), "DC=xxx,DC=xxx");
}
我正在使用spring security进行ldap身份验证。我收到以下错误:
原因:
[LDAP:错误代码16 - 00002080:AtrErr:DSID-03080155,#1:0:00002080:DSID-03080155,问题1001(NO_ATTRIBUTE_OR_VAL),数据0,Att 23(userPassword)];嵌套异常是javax.naming.directory.NoSuchAttributeException:[LDAP:错误代码16 - 00002080:AtrErr:DSID-03080155,#1:0:00002080:DSID-03080155,问题1001(NO_ATTRIBUTE_OR_VAL),数据0,Att 23(userPassword) )];
从例外情况看,您的ldap数据库似乎没有名为userPassword
的属性。您是否验证过您在配置中添加的属性与ldap中的属性完全相同?您的问题将通过提供确切的属性名称来解决。