春天安全ldaps认证

时间:2015-07-27 10:07:05

标签: java spring security ssl ldap

这个方法让我登录到活动目录服务器。 @组态     protected static class AuthenticationConfiguration扩展GlobalAuthenticationConfigurerAdapter {

    @Override
    public void init(AuthenticationManagerBuilder auth) throws Exception {
        DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(
                "ldap://qwerty:389");
        contextSource.setBase("DC=abc,DC=com");
        contextSource.setUserDn("user");
        contextSource.setPassword("pass");
        contextSource.setReferral("follow");
        contextSource.afterPropertiesSet();

        LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder> ldapAuthenticationProviderConfigurer = auth
                .ldapAuthentication();

        ldapAuthenticationProviderConfigurer.userSearchFilter("(&(sAMAccountName={0}))").userSearchBase("")
                .contextSource(contextSource);
    }
}

在我的应用程序中,我必须使用ldap而不是ssl,所以我将端口号更改为636并将ldap更改为ldaps,但现在我无法登录。

0 个答案:

没有答案