spring boot security ldap authentication throws在LDAP处理期间发生未分类的异常

时间:2018-01-25 14:23:00

标签: spring spring-security spring-ldap

我是春天的初学者。目前,我正在尝试Spring LDAP身份验证,但我得到了例外。无法找到解决方案。

有时我会遇到这个例外:

引起:org.springframework.ldap.CommunicationException:domain.com:389;嵌套异常是javax.naming.CommunicationException:domain.com:389 [Root exception is java.net.ConnectException:Connection timed out:connect]

还有: 您的登录尝试失败,请重试。

原因:LDAP处理期间发生了未分类的异常;嵌套异常是javax.naming.NamingException:[LDAP:错误代码1 - 000004DC:LdapErr:DSID-0C0907C2,注释:为了执行此操作,必须在连接上完成成功绑定。,data 0,v2580];剩余名称'uid = r.rashmi,ou =用户'

有人可以帮助我,我哪里出错了。

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

private static final Logger log = LoggerFactory.getLogger(WebSecurityConfig.class);

// AuthenticationManagerBuilder provides a mechanism to get a user based on the
// password encoder, datasource,
// userquery

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {

    auth.ldapAuthentication()
            .userDnPatterns("ldap://domain.com:389/", "dc=domain,dc=com")
            .groupSearchBase("ou=Project").userSearchBase("dc=domain,dc=com ").userSearchFilter("uid={0}")
            .contextSource().url("ldap://domain.com:389/dc=domain,dc=com").and().passwordCompare()
            .passwordEncoder(new LdapShaPasswordEncoder()).passwordAttribute("userPassword");

}

@Override
protected void configure(HttpSecurity http) throws Exception {

    http.authorizeRequests().anyRequest().fullyAuthenticated().and().formLogin();

}

}

ldapconfig.ldif

dn: ou=Users,ou=Project,dc=domain,dc=com

objectclass: user

userPassword: {SHA}hgjhghghg

application.properties

spring.ldap.embedded.ldif =类路径:ldapconfig.ldif

如果不使用.ldif进行身份验证,是否无法进行身份验证?

0 个答案:

没有答案