Active directory Spring Security 3.1 ActiveDirectoryLdapAuthenticationProvider返回部分结果异常

Active directory Spring Security 3.1 ActiveDirectoryLdapAuthenticationProvider返回部分结果异常,active-directory,spring-security,Active Directory,Spring Security,我正在尝试使用spring security对Active Directory实例的用户进行身份验证,但得到的是部分结果异常。我在兜圈子,想弄明白这一点。下面是我的配置 安全应用程序上下文 我犯了一个错误 org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size: expected 1, actual 0 org.springframework.security.

我正在尝试使用spring security对Active Directory实例的用户进行身份验证,但得到的是部分结果异常。我在兜圈子,想弄明白这一点。下面是我的配置

安全应用程序上下文


我犯了一个错误

 org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size: expected 1, actual 0        org.springframework.security.ldap.SpringSecurityLdapTemplate.searchForSingleEntryInternal(SpringSecurityLdapTemplate.java:239)
我正在努力寻找示例,文档表明我的工作方向是正确的

这是从日志中得到的

SpringSecurityLdapTemplate.java 213 - Searching for entry under DN '', base = 'dc=myDomain,dc=com', filter = '(&(objectClass=user)(userPrincipalName={0}))'
这就是我所期望的,从一些有效的脚本中成功尝试的结果

Searching for entry under DN 'OU=Users and Groups,DC=one,DC=two,DC=myDomain,DC=com', base = 'OU=Users and Groups,DC=one,DC=two,DC=myDomain,DC=com', filter = '(&(objectClass=user)(userPrincipalName={0}))'

我需要填充DN吗?怎么用?我已经查看了ActiveDirectoryLdapAuthenticationProvider属性,但没有找到解决方法?此外,基地是关闭的,但myDomain.com是用户的正确域名,例如john。doe@myDomain.com. 有人遇到过类似的问题吗?

为了解决这个问题,我使用了默认的LDAP提供程序,它允许指定用户搜索库,指定用户搜索库和用户搜索过滤器



然后,用户将与john一起登录。doe@myDomain.com但用户搜索库更为具体(abc.myDomain.com)。我相信AD Spring正是因为这个原因而崩溃的。

过滤器是否对相关用户有效?如果没有,您可能遇到报告的问题。您好,Luke,用户筛选器有效,但基数不太具体,并且尚未设置DN。尝试使用带有spring值的ldapsearch命令行工具(无DN,不太具体的基数,但有用户进行绑定和搜索)时,我收到一个错误,但当我使用“OU=”指定完整基数时我得到了成功的回报。我已经读到,转介会导致active directory出现问题,也许这就是问题所在。同时,我将查看其他身份验证提供者的身份验证,或者编写自己的身份验证提供者身份验证(如果没有)。感谢您的帮助。@Luke Taylor我使用了ldap身份验证提供程序,该提供程序定义了用户搜索库,可以正常工作。我不知道为什么ActiveDirectory验证器不起作用,但我猜这是因为当搜索范围缩小时,它成功返回了引用。你能粘贴包括配置文件在内的完整代码吗。