Announcement Announcement Module
Collapse
No announcement yet.
Spring security 3.1 authentication LDAP with md5 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring security 3.1 authentication LDAP with md5

    When we try to authenticate using the spring authentication manager, its says "bad credentials":

    HTML Code:
    Authentication request = new UsernamePasswordAuthenticationToken("john", "johnldap");
    result = authenticationManager.authenticate(request);
    Here the SecurityApplicationContext.xml file:

    HTML Code:
    <authentication-manager alias="authenticationManager">
            <ldap-authentication-provider server-ref="ldapLocal"
                user-dn-pattern="uid={0},ou=People">         
            </ldap-authentication-provider> 
        </authentication-manager>
        <ldap-server url="ldap://127.0.0.1:389/dc=example,dc=com" manager-dn="admin" manager-password="xxxxxxxx" id="ldapLocal"  />
    However using "ldapsearch" we can connect successfully:

    HTML Code:
    ldapsearch -D "uid=john,ou=People,dc=example,dc=com" -w johnldap  -L "objectClass=*"
    At first time we thought the issue was that we've to tell spring to do a md5 of the password before call LDAP. So we add it to the applicationSecurtyContext.xml:

    HTML Code:
     <beans:bean id="passwordEncoder"  class="org.springframework.security.authentication.encoding.Md5PasswordEncoder">
        </beans:bean>
        <authentication-manager alias="authenticationManager">
            <ldap-authentication-provider server-ref="ldapLocal"
                user-dn-pattern="uid={0},ou=People">  
             <password-compare>
                <password-encoder ref="passwordEncoder"> </password-encoder>
            </password-compare>
            </ldap-authentication-provider> 
        </authentication-manager>
        <ldap-server url="ldap://127.0.0.1:389/dc=example,dc=com" manager-dn="admin" manager-password="xxxxxxxx" id="ldapLocal"  />
    But when we add the tag it says:

    LDAP: error code 34 - invalid DN]

    What's wrong here?
Working...
X