0

我正在尝试通过 Spring Boot 应用程序中的安全 adlds 服务器对用户进行身份验证,现在我面临一个问题 2 周,在互联网上没有找到适合我的解决方案。

首先我有一个错误,说我需要在成功操作之前绑定身份验证。我在上下文源中添加了正确的属性,但现在我得到一个错误代码 80,它没有给我任何关于错误的线索。

这是我的代码:

应用程序.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形之间的单词是隐藏的,我不允许显示凭据等。

请问您有解决该问题的任何线索吗?这非常关键

此致,

4

1 回答 1

0

在错误消息中,data 20ee表示 Windows 系统错误代码。根据微软文档,即:

ERROR_DS_INTERNAL_FAILURE

8430 (0x20EE)

目录服务遇到内部故障。

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

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

作为旁注,如果您ldaps://在路径中指明,则不需要包含:636,因为这是默认的 LDAPS 端口。

于 2022-01-01T16:40:57.453 回答