spring-security 使用ldap时出现AcceptSecurityContext错误

kxeu7u2r  于 2022-11-11  发布在  Spring
关注(0)|答案(1)|浏览(329)

我有问题。这是我的代码验证与ldap
但是它有错误,告诉我AcceptSecurityContext。
验证异常:[LDAP:错误代码49 - 80090308:登录错误:DSID-0 C 090400,备注:接受安全上下文错误,数据52 e,v1 db 1]
请帮帮我

@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;
        }

相关问题