[英]Unable to Authenticate a User with an LDAP Server using LDAP User Search Query with Spring Security
Root DSE: 根DSE:
DC=company,DC=com DC =公司,DC = COM
OU=Offices OU =办事处
OU=Region Offices OU =地区办事处
OU=Region1 Office OU = Region1 Office
OU=Users OU =用户
CN=Jayesh Mulwani CN = Jayesh Mulwani
public class LDAPSecurityConfig extends WebSecurityConfigurerAdapter{
protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
authenticationManagerBuilder.ldapAuthentication()
.contextSource().url("ldap://server-url/CN=auth_support,OU=Misc,DC=company,DC=com")
.managerDn("username").managerPassword("password")
.and()
.userSearchBase("OU=Offices,DC=company,DC=com")
.userSearchFilter("(&(objectClass=user)(cn={0}))");
}
}
Once the application is setup on tomcat, i enter the username along with its password but the authentication fails and no error is prompted. 在Tomcat上安装了应用程序后,我输入了用户名及其密码,但是身份验证失败,并且未提示任何错误。
Can someone please assist me with the approach or specify if i'm missing something here ? 有人可以协助我采取这种方法,还是指定我在这里是否缺少什么?
I have fixed the problem by adding the below two conditions 我通过添加以下两个条件解决了该问题
.groupSearchFilter("(&(objectClass=group)(AccountName={0}))")
.groupSearchBase("CN=DEPT_All_Employees,OU=DepartmentSecurityGroups,OU=Resources,DC=company,DC=com")
I referred this example to fix the issue http://www.jcombat.com/spring/spring-security-ldap-authentication 我引用了这个示例来解决此问题, 网址为http://www.jcombat.com/spring/spring-security-ldap-authentication
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.