Reputation: 5264
I am trying to configure Spring Security with LDAP
using OpenLDAP server, I am configuring it to be redirected to my own LoginController
when the user open the application. However every time it I try to connect to the application it throws an AccessDeniedException, it never enters my LoginController
Here is my configuration:
<bean name="/login" class="controller.LoginController" />
<s:ldap-server url="ldap://localhost:389/dc=maxcrc,dc=com" />
<s:http pattern="/login*" security="none" />
<s:http auto-config="true" use-expressions="true">
<s:intercept-url pattern="/**" access="isAuthenticated()" />
<s:logout invalidate-session="true" logout-url="/logout" logout-success-url="/login" />
<s:form-login login-page="/login" login-processing-url="/j_spring_security_check" />
</s:http>
<s:authentication-manager alias="authenticationManager">
<s:ldap-authentication-provider user-dn-pattern="uid={0},ou=people" />
</s:authentication-manager>
And here is my LoginController
public class LoginController extends AbstractController {
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) {
return new ModelAndView("LOGIN");
}
}
Upvotes: 1
Views: 740
Reputation: 1745
Check that you have access to ldap server anonymously, because you not specified an account to connect, like in this sample:
<security:ldap-server url="ldap://localhost:10389/o=mojo"
manager-dn="uid=admin,ou=system" manager-password="secret" />
Here is a good tutorial to make ldap authentication correctly: http://krams915.blogspot.ru/2011/01/spring-security-mvc-using-ldap.html
Upvotes: 1