【发布时间】:2017-02-24 00:09:08
【问题描述】:
我是 Active Directory 和 Spring Security 的新手,事实上,我想更改我的 Spring Security 配置以便在身份验证中使用 Active Directory,所以我在我的 SecurityConfig 中使用它:
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(activeDirectoryLdapAuthenticationProvider());
auth.eraseCredentials(false);
}
@Bean
public AuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
ActiveDirectoryLdapAuthenticationProvider authenticationProvider = new ActiveDirectoryLdapAuthenticationProvider(
"dc=example,dc=com", "ldap://localhost:10389/dc=example,dc=com");
authenticationProvider.setConvertSubErrorCodesToExceptions(true);
authenticationProvider.setUseAuthenticationRequestCredentials(true);
authenticationProvider.setUserDetailsContextMapper(mapper);
return authenticationProvider;
}
和活动目录工作室我有一个分区:dc=example,dc=com,其中包含一个条目ou=people。
当我尝试输入用户名和密码时,出现以下错误:
javax.naming.InvalidNameException: [LDAP: 错误代码 34 - 给定的 DN 不正确:admin@dc=example,dc=com (0x73 0x79 0x73 0x61 0x64 0x6D 0x69 0x6E 0x40 0x64 0x63 0x3D 0x70 0x75 0x70 0x70 0xC 0x76 0x63 0x3D 0x63 0x6F 0x6D ) 无效] 在 com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3076) 在 com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2883) 在 com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2797)..
请问你有什么想法吗?
【问题讨论】:
-
如果您使用的是 Mac,请确保您的 build.xml 文件中没有任何
"
标签: spring-security active-directory ldap