1

我目前有一个 Spring-boot 应用程序,它从 Active Directory 获取员工数据,并将它们显示为 JSON。

但是,我不想直接链接到 Active Directory,我想使用 Active Directory 轻量级服务。

我以为我可以设置连接并以相同的方式连接,但我不断收到错误 49(无效凭据)错误。我正在使用与 Active Directory 相同的凭据。

这是 Spring.xml 配置凭据:

 <bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
        <property name="url" value="ldap://example.com:389" />
        <property name="base" value=" DC=example,DC=com" />
        <property name="userDn" value="jsmith@example.com" />
        <property name="password" value="password" />
    </bean>

    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
        <constructor-arg ref="contextSource" />
        <property name="ignorePartialResultException" value="true" />
    </bean>

如果我尝试将 url 更改为 AD LDS url(使用 localhost),我会收到 Ldap 错误 49。有人对这些技术有经验吗?请帮忙。

编辑:

如果我尝试使用我的 Active Directory 域用户名,我会得到:

The authentication failed
 - [LDAP: error code 49 - 8009030C: LdapErr: DSID-0C0903C4, comment: AcceptSecurityContext error, data 2030, v295a

如果我尝试使用 userDN,我会得到:

The authentication failed
 - [LDAP: error code 80 - 80090304: LdapErr: DSID-0C0903C4, comment: AcceptSecurityContext error, data 20ee, v295a
4

2 回答 2

0

我自己遇到了这个问题并且能够解决它。我遇到的问题是我的 AD LDS 配置了 SASL,所以做一个简单的绑定不起作用。有关 SASL 的说明,请参阅 LDAPv3 身份验证方法rfc2829(第 6.1 节)。

我将介绍如何使用 Apache Directory Studio 设置连接,但我确信 Spring 文档描述了如何为您的连接配置 SASL。

配置与服务器的连接在我的测试实验室中,我没有使用 TLS 进行保护,因此我只能绑定到 389。

配置身份验证配置身份验证时,您要选择 LDAPv3 服务器支持的 SASL 方法(我的 AD LDS 支持 DIGEST-MD5)。输入用户和密码的凭据(我可以使用屏幕截图中提供的完整 DN,以及 cn)。使用 DIGEST-MD5 身份验证方法时,您还必须在 SASL 设置下提供一个 SASL 领域。这是用于绑定的 Principal 的领域。

如果要检查 LDAP 服务器(如 AD LDS)支持的 SASL 方法,可以使用 ldp.exe(或 Softerra)工具检索绑定元数据并查找支持的 LDAP SASL 方法。

于 2019-02-07T13:54:42.753 回答
0

您需要提供用户的完整 DN 作为“userDn”,如 cn=jsmith@example.com,ou=xyz,dc=abc,dc-com。

于 2016-12-07T11:49:17.063 回答