【发布时间】:2016-09-04 16:17:05
【问题描述】:
我正在尝试在我的 Spring MVC 应用程序上为 LDAP 身份验证设置 Spring Security。我似乎无法让简单/主要身份验证与 LdapAuthenticationProvider 一起使用,因此我尝试使用默认情况下执行此操作的 ActiveDirectoryLdapAuthenticationProvider。
在创建上下文后(并且我认为 LDAP 绑定已经发生),我从该行(ActiveDirectoryLdapAuthenticationProvider.java 中的 310)得到一个 NameNotFoundException 和 detailMessage:
return SpringSecurityLdapTemplate.searchForSingleEntryInternal(context,
searchControls, searchRoot, searchFilter,
new Object[] { bindPrincipal });
错误信息:
[LDAP: error code 32 - 0000208D: NameErr: DSID-03100213, problem 2001 (NO_OBJECT), data 0, best match of:
'DC=my,DC=company,DC=com']
搜索过滤器正在寻找一个具有“user”类的对象,该对象的 userPrincipalName 等于我进行身份验证时使用的用户名,并与我的域的域名连接。例如,“me@my.company.com”。具有该值的属性存在,因为我可以在此方法中使用 JXplorer 进行身份验证,然后执行该搜索以找到我的用户对象。
我的 WebSecurityConfigurerAdapter 子类的配置,我在 AuthenticationManagerBuilder 中连接,基本上是这样的:
@Autowired
public void init(AuthenticationManagerBuilder auth) throws Exception {
ActiveDirectoryLdapAuthenticationProvider provider =
new ActiveDirectoryLdapAuthenticationProvider("my.company.com", "LDAPS://ad.my.company.com:636/dc=my,dc=company,dc=com");
provider.setConvertSubErrorCodesToExceptions(true);
auth.authenticationProvider(provider);
}
是什么导致了 NameNotFoundException?这是配置 ActiveDirectory 身份验证的正确方法吗?
【问题讨论】:
标签: spring spring-security spring-security-ldap