[英]LDAP authentication with Spring Security
使用凭据登录 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 安全性进行 ldap 身份验证。 我收到以下错误:
原因:
[LDAP: error code 16 - 00002080: AtrErr: DSID-03080155, #1: 0:
00002080: DSID-03080155, problem 1001 (NO_ATTRIBUTE_OR_VAL), data 0,
Att 23 (userPassword) ]; nested exception is
javax.naming.directory.NoSuchAttributeException: [LDAP: error code 16
- 00002080: AtrErr: DSID-03080155, #1: 0: 00002080: DSID-03080155, problem 1001 (NO_ATTRIBUTE_OR_VAL), data 0, Att 23 (userPassword) ];
从异常来看,您的 ldap 数据库似乎没有名为userPassword
的属性。 您是否确认您在配置中放置的属性与 ldap 中的命名完全相同? 您的问题将通过提供确切的属性名称来解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.