相关疑难解决方法(0)

如何通过LDAP over TLS对Active Directory进行身份验证?

我有一个工作概念验证应用程序,它可以在测试服务器上通过LDAP成功验证Active Directory,但生产应用程序必须通过TLS进行验证 - 域控制器关闭任何不通过TLS启动的连接.

我已经在Eclipse中安装了LDAP浏览器,我确实可以在其中使用TLS绑定,但我不能在我的生活中弄清楚如何让我的应用程序使用TLS.

ldap.xml:

<bean id="ldapAuthenticationProvider"
        class="my.project.package.OverrideActiveDirectoryLdapAuthenticationProvider">

    <!-- this works to authenticate by binding as the user in question -->
    <constructor-arg value="test.server"/>
    <constructor-arg value="ldap://192.168.0.2:389"/>

    <!-- this doesn't work, because the server requires a TLS connection -->
    <!-- <constructor-arg value="production.server"/> -->
    <!-- <constructor-arg value="ldaps://192.168.0.3:389"/> -->

    <property name="convertSubErrorCodesToExceptions" value="true"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

OverrideActiveDirectoryLdapAuthenticationProvider是一个覆盖类,它扩展了Spring ActiveDirectoryLdapAuthenticationProvider类的副本,由于某种原因被指定final.我覆盖的原因与自定义用户对象上填充权限/权限的方式有关(我们将使用相关组的组成员身份来构建用户的权限,或者我们将从AD用户对象的字段中读取).在其中,我只是重写loadUserAuthorities()方法,但我怀疑我可能还需要覆盖bindAsUser()方法或可能的doAuthentication()方法.

XML和一个覆盖类是我的应用程序管理身份验证的唯一两个地方,而不是让Spring完成工作.我已经阅读了几个要启用TLS的地方我需要扩展DefaultTlsDirContextAuthenticationStrategy类,但是我在哪里连接它?是否有命名空间解决方案?我是否需要完全做其他事情(即放弃使用Spring ActiveDirectoryLdapAuthenticationProvider而改为使用LdapAuthenticationProvider)?

任何帮助表示赞赏.

java ldap active-directory spring-security spring-security-ldap

4
推荐指数
1
解决办法
6063
查看次数