【发布时间】:2020-02-16 06:02:35
【问题描述】:
我无法使用真实的活动目录进行身份验证,让我更好地解释一下我尝试使用 spring.io 提出的示例进行身份验证,没有问题,内部服务启动没有任何问题。 参考https://spring.io/guides/gs/authenticating-ldap/
我尝试通过插入我的活动目录的配置来修改下面的代码,但没有成功。您能否指导我或向我展示一个真实的案例,即在不使用示例中的内部服务的情况下建立真正的连接?我上网查了一下,发现都和官方的例子差不多,没有任何真实案例
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource()
.url("ldap://localhost:8389/dc=springframework,dc=org")
.and()
.passwordCompare()
.passwordEncoder(new LdapShaPasswordEncoder())
.passwordAttribute("userPassword");
}
错误显示: LDAP 处理期间发生未分类异常;嵌套异常为 javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C0907C2,注释:为了执行此操作,必须在连接上成功绑定。,数据 0,v2580
【问题讨论】:
-
基于 LDAP 的做法是搜索 EntryDN,然后使用找到的 DN 和提供的密码执行身份验证。很奇怪,该指南显示使用 DN 合作伙伴作为首选。只有在极少数情况下,目录信息树才会是“平面”树。密码比较也是不好的做法。
-
通常也不允许匿名访问生产目录服务器,因此您需要一个“服务帐户”(特殊的 Bind-DN),可用于对目录服务器执行 LDAP 操作。跨度>
标签: spring spring-security active-directory ldap spring-ldap