springsecurityldap首先进行身份验证

springsecurityldap首先进行身份验证,ldap,spring-security,Ldap,Spring Security,我已经使用以下配置设置了ldap身份验证。我只需要让用户对LDAP数据存储进行身份验证,然后让他们的会话获得身份验证令牌。通过阅读文档,我认为这是应该发生的: 作为管理员进行身份验证,根据搜索条件查找用户的完整dn 尝试以用户身份绑定(使用其完整dn)和提供的密码 日志似乎没有提供足够的信息来说明这一失败的原因。它只是说无效的凭据-当我知道它们是有效的。我的想法是发生了以下事情之一: 找不到用户的完整DN,他们正在使用用户名进行身份验证 它尝试进行密码比较,而不是实际尝试绑定到目录 配置: &l

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

  • 作为管理员进行身份验证,根据搜索条件查找用户的完整dn
  • 尝试以用户身份绑定(使用其完整dn)和提供的密码
  • 日志似乎没有提供足够的信息来说明这一失败的原因。它只是说无效的凭据-当我知道它们是有效的。我的想法是发生了以下事情之一:

  • 找不到用户的完整DN,他们正在使用用户名进行身份验证
  • 它尝试进行密码比较,而不是实际尝试绑定到目录
  • 配置:

    <ldap-server 
        url="ldap://adapps.company.com:389/dc=company,dc=com" 
        manager-dn="cn=fulluserdn,dc=company,dc=com" 
        manager-password="password"/>
    <ldap-user-service user-search-base="" user-search-filter="(samaccountname={0})"/>  
    <authentication-manager>
    <ldap-authentication-provider user-search-filter="(samaccountname={0})" user-search-base="dc=company,dc=com"/>
    </authentication-manager>
    

    问题在于测试LDAP服务器在其他端口上运行,但正常端口仍然打开。

    问题在于测试LDAP服务器在其他端口上运行,但正常端口仍然打开

    [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