【问题标题】:Spring Security LDAP Server Connection Not '127.0.0.1'Spring Security LDAP 服务器连接不是“127.0.0.1”
【发布时间】:2020-07-18 14:38:17
【问题描述】:

我有一个 ldap 服务器,我想在这个 ldap 上使用 spring security。我的连接配置是:

@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

@Override 
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    // TODO Auto-generated method stub
    auth.ldapAuthentication()
    .userDnPatterns("OU=*****")
    .userSearchFilter("(uid={0})")    
    .groupSearchBase("OU=*****")
    .contextSource()
    .root("DC=*****,DC=*****,DC=*****") 
    .port(389);




}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.authorizeRequests().anyRequest().fullyAuthenticated().and().formLogin();
} 

}

但是当我运行我的 spring boot 应用程序时,它会尝试连接 ldap://127.0.0.1:389,我如何访问我的 ldap 服务器?我的 ldap 服务器网址是:LDAP://xxx.com.tr

我的错误是什么?

【问题讨论】:

    标签: spring-boot spring-security ldap spring-security-ldap


    【解决方案1】:

    我在 Spring 安全性中没有看到任何配置来指定 LDAP URL。

    尝试使用url指定LDAP服务器,否则默认使用localhost...

      @Override
      public void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth
          .ldapAuthentication()
              .userDnPatterns("OU=*****")
              .userSearchFilter("(uid={0})")    
              .groupSearchBase("OU=*****")
            .contextSource()
              .url("ldap://xxx.com.tr:389/dc=***,dc=***,dc=***");
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-26
      • 2015-01-18
      • 2016-08-29
      • 2022-10-04
      • 1970-01-01
      • 2016-04-13
      • 2022-01-25
      相关资源
      最近更新 更多