【问题标题】:Spring Boot LDAP - Eror code 80 when trying to auth usersSpring Boot LDAP - 尝试对用户进行身份验证时出现错误代码 80
【发布时间】: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形之间的单词是隐藏的,我不允许显示凭据等。

请问您有解决该问题的线索吗?这很关键

最好的问候,

【问题讨论】:

标签: spring-boot spring-security ldap ldap-query adlds


【解决方案1】:

在错误消息中,data 20ee 表示 Windows 系统错误代码。根据Microsoft documentation,即:

ERROR_DS_INTERNAL_FAILURE

8430 (0x20EE)

目录服务遇到内部故障。

我不认为这表明您的代码有任何问题。这听起来更像是您的 Active Directory 环境的问题。

您是否尝试过通过常规 LDAP 而不是 LDAPS 进行连接? (ldap://&lt;hostname&gt;)。如果可行,则表明 LDAPS 配置存在问题。

附带说明,如果您在路径中指明 ldaps://,则无需包含 :636,因为这是默认的 LDAPS 端口。

【讨论】:

  • 您好,谢谢您的回答。我将尝试在没有 LDAPS 的情况下进行连接,但我认为我没有被授权,因为它是一个生产 AD。但是微软文档对我帮助很大,我会和 AD 管理员讨论。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-12-25
  • 1970-01-01
  • 2015-11-22
  • 1970-01-01
  • 2019-04-09
  • 2011-05-25
  • 2018-02-22
相关资源
最近更新 更多