0
votes

I want to authenticate with ldap-server with spring security, here it is my security.xml:

<http auto-config="true" use-expressions="true">
    <intercept-url pattern="/index*" access="permitAll" />
    <form-login login-page="/login" default-target-url="/index"
        authentication-success-handler-ref="loginSuccessHandler"
        authentication-failure-handler-ref="loginFailureHandler" />
</http>

<ldap-server id="ldapServer"
    url="ldap://example.net:389/DC=example,DC=net" />
<authentication-manager>
    <ldap-authentication-provider server-ref="ldapServer"
        user-dn-pattern="CN={0}, OU=First,OU=Second,OU=Third>
    </ldap-authentication-provider>
</authentication-manager>

But it throws an exception - "Caused by: javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C0906E8, comment: In order to perform this operation a success ful bind must be completed on the connection., data 0, v1db1 ]; remaining name ''"

What is wrong?

1
You're not binding to the LDAP server. - duffymo
How can I do it? With BindAuthenticator? - Shallow
Server name, port, DN are correct, I checked them with ldapExplorer. One of ldapExplorer throws exception when I use "Anonymous" type authentication for ldap-server. But I haven't manager's password, so I think I need to set user login and password to connect to ldap and then check this login and password with ldap server. It's wierd.. - Shallow

1 Answers

0
votes

Check that the LDAP client is using LDAPv3. LDAPv2 requires the first operation on a connection be the BIND operation. Generally speaking, LDAP clients should not use LDAPv2 and existing code should be modified to not use LDAPv2.