Spring安全ldap验证

Spring安全ldap验证,ldap,spring-security,Ldap,Spring Security,我已经使用以下配置设置了ldap身份验证。我只需要让用户对LDAP数据存储进行身份验证,然后让他们的会话获得身份验证令牌。通过阅读文档,我认为这是应该发生的: applicationContextSecurity.xml <ldap-server id="contextSource" url="ldap://192.168.0.1:389/DC=cn,DC=bleum,DC=com" manager-dn="cn=buddy,ou=Neil,OU=Development,O

我已经使用以下配置设置了ldap身份验证。我只需要让用户对LDAP数据存储进行身份验证,然后让他们的会话获得身份验证令牌。通过阅读文档,我认为这是应该发生的:

applicationContextSecurity.xml

<ldap-server id="contextSource"
  url="ldap://192.168.0.1:389/DC=cn,DC=bleum,DC=com"
     manager-dn="cn=buddy,ou=Neil,OU=Development,OU=Micosoft,DC=cn,DC=Micosoft,DC=com" 
     manager-password="A,1234567890" />

 <authentication-manager alias="authenticationManager" erase-credentials="true"> 
    <!--<authentication-provider user-service-ref="securityManagerSupport"/> -->
    <ldap-authentication-provider server-ref="contextSource" role-prefix="none" user-search-filter="(uid={0})" 
         user-search-base="ou=Neil,OU=Development,OU=Micosoft" user-context-mapper-ref="contextMapper">
    </ldap-authentication-provider>
 </authentication-manager>

 <beans:bean id="contextMapper" class="com.micosoft.neil.security.UserDetailsContextMapperSupport"/>


Error:

[DEBUG,FilterBasedLdapUserSearch] Searching for user 'test', with user search [ searchFilter: '(samaccountname={0})', searchBase: 'dc=company,dc=com', scope: subtree, searchTimeLimit: 0, derefLinkFlag: false ]
[DEBUG,AbstractContextSource] Got Ldap context on server 'ldap://adapps.company.com:389/dc=company,dc=com'
[INFO,SpringSecurityLdapTemplate] Ignoring PartialResultException
[DEBUG,XmlWebApplicationContext] Publishing event in Root WebApplicationContext: org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent[source=org.springframework.security.authentication.UsernamePasswordAuthenticationToken@488b5f0b: Principal: test; Password: [PROTECTED]; Authenticated: false; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@fffd148a: RemoteIpAddress: 127.0.0.1; SessionId: 0718B7EED3F930C63C03DA97C4344CBD; Not granted any authorities]
[DEBUG,UsernamePasswordAuthenticationFilter] Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Bad credentials
[DEBUG,UsernamePasswordAuthenticationFilter] Updated SecurityContextHolder to contain null Authentication
[DEBUG,UsernamePasswordAuthenticationFilter] Delegating to authentication failure handlerorg.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler@395158
[DEBUG,TokenBasedRememberMeServices] Interactive login attempt was unsuccessful.
[DEBUG,TokenBasedRememberMeServices] Cancelling cookie
applicationContextSecurity.xml
错误:
[DEBUG,FilterbasedapUserSearch]搜索用户“test”,使用用户搜索[searchFilter:'(SamaAccountName={0}'),searchBase:'dc=company,dc=com',作用域:子树,searchTimeLimit:0,derefLinkFlag:false]
[DEBUG,AbstractContextSource]已在服务器上获取Ldap上下文ldap://adapps.company.com:389/dc=company,dc=com'
[信息,SpringSecurityLdapTemplate]忽略PartialResultException
[DEBUG,XmlWebApplicationContext]根WebApplicationContext中的发布事件:org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent[source=org.springframework.security.authentication。UsernamePasswordAuthenticationToken@488b5f0b:主体:测试;密码:[受保护];已验证:false;详细信息:org.springframework.security.web.authentication。WebAuthenticationDetails@fffd148a:RemoteIP地址:127.0.0.1;会话ID:0718B7EED3F930C63C03DA97C4344CBD;未授予任何权限]
[DEBUG,UsernamePasswordAuthenticationFilter]身份验证请求失败:org.springframework.security.Authentication.BadCredentialsException:错误的凭据
[DEBUG,UsernamePasswordAuthenticationFilter]已更新SecurityContextHolder以包含空身份验证
[DEBUG,UsernamePasswordAuthenticationFilter]授权验证失败handlerorg.springframework.security.web.authentication。SimpleUrlAuthenticationFailureHandler@395158
[调试,TokenBasedMemberMeservices]交互式登录尝试失败。
[调试,TokenBasedMemberMeservices]取消cookie

从结果来看,密码似乎不正确,因此,如果您试图输入错误的用户/密码,那么是的,这就是预期的结果


真的不知道你的问题是什么?你是不是期待一些不同的东西?您传递了正确的凭据吗?

我在几乎相同的配置中遇到了相同的错误。我还不能给你一个答案(抱歉!),但是通过Spring类运行调试器,看起来他们试图将用户以字符串形式输入的密码(调试器确认它是正确的密码)与从LDAP检索到的密码进行比较,该密码为空,然后失败