【发布时间】:2019-12-11 14:14:12
【问题描述】:
我有问题。这是我使用 ldap 进行身份验证的代码
在春天,但它有错误告诉我 AcceptSecurityContext。
javax.naming.AuthenticationException:[LDAP:错误代码 49 - 80090308:LdapErr:DSID-0C090400,注释:AcceptSecurityContext 错误,数据 52e,v1db1]
请帮帮我
@GetMapping("/login/{userName}/{password}")
public Map<String, Boolean> login(@PathVariable(value = "userName") String username,@PathVariable(value = "password") String password) throws Exception {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(url);
contextSource.setUserDn("userPrincipalName=arpa@msv.net");
contextSource.setPassword("masterone4408$$)*");
contextSource.afterPropertiesSet();
LdapTemplate ldapTemplate=new LdapTemplate(contextSource);
AndFilter filter = new AndFilter();
System.out.println(username+"////"+password);
filter.and(new EqualsFilter("cn", username));
ldapTemplate.afterPropertiesSet();
Map<String, Boolean> response = new HashMap<>();
response.put("deleted", ldapTemplate.authenticate(DistinguishedName.EMPTY_PATH,"(&(userPrincipalName="+username+"@msv.net))", password));
return response;
}
【问题讨论】:
标签: java spring spring-boot spring-security ldap