【发布时间】:2021-12-31 11:53:50
【问题描述】:
我正在尝试通过 Spring Boot 应用程序中的安全 adlds 服务器对用户进行身份验证,我现在面临 2 周的问题,但在互联网上没有找到适合我的解决方案。
首先我遇到一个错误,说我需要在成功操作之前绑定身份验证。我在上下文源中添加了正确的属性,但现在我得到一个错误代码 80,它没有给我任何关于错误的线索。
这是我的代码:
Application.yml
spring:
ldap:
url: ldaps://<hostname>:636
base: DC=<dc>>,DC=<dc>
username: CN=<cn>>,OU=Privileged,OU=<ou>,OU=<ou>,OU=<ou>,DC=<dc>,DC=<dc>
password: <secret>
base-environment:
com.sun.jndi.ldap.connect.timeout: 500
management:
health:
ldap:
enabled: false
配置.java
@Bean
@DependsOn("frameworkInstance")
public LdapContextSource contextSource() {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldaps://<hostname>:636");
contextSource.setBase("<base>");
contextSource.setUserDn("CN=<cn>,OU=<ou>>,OU=<ou>>,OU=<ou>>,OU=<ou>,DC=<dc>,DC=<dc>>");
contextSource.setPassword("<secret>");
contextSource.afterPropertiesSet();
return contextSource;
}
@Bean
@DependsOn("frameworkInstance")
public LdapTemplate ldapTemplate() {
return new LdapTemplate(contextSource());
}
我的认证过程:
Filter filter = new EqualsFilter("cn", "<cn>");
ldapTemplate.authenticate(LdapUtils.emptyLdapName(), filter.encode(), "<secret>");
错误代码是:
Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: [LDAP: error code 80 - 80090304: LdapErr: DSID-0C090447, comment: AcceptSecurityContext error, data 20ee, v3839\u0000]
我尝试了几天但没有任何结果......用于“绑定”和身份验证的帐户是相同的,以确保身份验证成功。请记住,由于生产环境,V形之间的单词是隐藏的,我不允许显示凭据等。
请问您有解决该问题的线索吗?这很关键
最好的问候,
【问题讨论】:
-
我会使用已知的 LDAP 工具来建立连接。 ldapsearch(命令行实用程序)或directory.apache.org/studio。错误代码 NOT 和 LDAP 错误以及一些服务器错误代码,所以我猜这是设置中的问题。另请看:social.technet.microsoft.com/Forums/en-US/…
标签: spring-boot spring-security ldap ldap-query adlds