0

我在我的项目中有特殊要求,指出应该使用特殊(“代理”)用户对 Active Directory 进行身份验证。也就是说,首先我们必须使用这个特殊用户登录到 AD,然后我们应该“查询”AD 关于“真实”用户(尝试登录我的应用程序的用户)的凭据是否正确,使用“代理”用户会话。

有没有办法使用弹簧安全性来做到这一点?...现在我正在使用org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider.

这些是我当前的依赖项:

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-core</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-ldap</artifactId>
        <version>3.2.5.RELEASE</version>
    </dependency>

这是通过spring的身份验证部分的配置:

<beans:bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
    <beans:constructor-arg>
        <beans:value>${security.ad.domain}</beans:value>
    </beans:constructor-arg>
    <beans:constructor-arg>
        <beans:value>${security.ad.url}</beans:value>
    </beans:constructor-arg>
</beans:bean>

<authentication-manager>
    <authentication-provider ref="ldapAuthProvider" />
</authentication-manager>

谢谢你的帮助!!

4

1 回答 1

0

我成功地尝试了你的场景。也许晚了,但它可能会帮助别人。首先,我按照此处所述设置我的项目。其次,我在WebSecurityConfig课堂上添加了以下内容:

@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception 
{
    auth
        .ldapAuthentication()
            // User Base DN
            .userDnPatterns("cn={0},ou=...,ou=...,o=...,c=...") 
            .contextSource()
                // ldap server
                .url("ldaps://server:636") 
                // Bind credentials Bind DN
                .managerDn("cn=...,ou=...,o=...,c=...") 
                // Bind credentials Bind Password
                .managerPassword("...");
}
于 2016-04-26T08:15:35.107 回答