java - 使用 spring 绑定到 LDAP
问题描述
如果有错误,我为英语道歉。我需要通过 LDAP 向我的 spring 程序添加授权,但是在尝试授权客户端时出现错误:
Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C0907E9, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v2580]; remaining name 'uid=ben,ou=Пользователи'
据我了解,这是服务器上的程序授权错误。有权使用 LDAP 协议在 AD 中搜索的帐户的凭据是通过 application.properties 设置的:
spring.ldap.username=
spring.ldap.password=
负责授权的代码片段与指南中的代码相同:
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("(uid={0}),ou=Пользователи")
.groupSearchBase("ou=groups")
.contextSource()
.url("xxx")
.and()
.passwordCompare()
.passwordEncoder(new BCryptPasswordEncoder())
.passwordAttribute("userPassword");
}
对Spring不是很了解,如有错误请指教。此错误是否与密码编码有关(在 passwordEncoder() 方法中)?
UPD.:服务器使用 389-Server
解决方案
对于解决方案,您需要在配置请求时指定系统帐户数据:
auth
.ldapAuthentication()
.userSearchBase("ou=Пользователи")
.userSearchFilter("sAMAccountName={0}")
.contextSource()
.url(sourceUrl)
.managerDn(managerLogin) // <--- this
.managerPassword(managerPassw); // <--- this
推荐阅读
- image - 从清单构建 Docker 映像
- reactjs - 当我尝试将 API 调用作为道具从一个组件传递到另一个组件时,承诺未决
- html - 我怎样才能让我的图像环绕我的文字?
- ecmascript-6 - Jasmine 测试依赖项:不能在模块外使用 import 语句
- stackdriver - Opencensus 高级聚合
- python - Python asyncio await-for timeout 不适用于无限任务
- python - QWidget 不接受大于大约 23000 的 setFixedSize 值
- ios - objective-c : 2 个 viewControllers 之间的自定义 segue 转换
- laravel - 使用 Guzzle 客户端获取 API 数据
- angular - Angular 10:下一次调用后订阅 observable 不会触发