简体   繁体   English

Spring 安全 LDAP 服务器连接不是“127.0.0.1”

[英]Spring Security LDAP Server Connection Not '127.0.0.1'

I've a ldap server and i want to use spring security with this ldap.我有一个 ldap 服务器,我想通过这个 ldap 使用 spring 安全性。 My connection configure is:我的连接配置是:

@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();
} 

} }

But when i run my spring boot app, it tries to connect ldap://127.0.0.1:389, how can i access my ldap server?但是当我运行我的 spring 启动应用程序时,它会尝试连接 ldap://127.0.0.1:389,我该如何访问我的 Z044063C23354128B636DF86F118ZFE 服务器? My ldap server url is: LDAP://xxx.com.tr我的 ldap 服务器 url 是:LDAP://xxx.Z4D236D9A2D102C5FE6AD1C50DA4BEC。

What is my mistake?我的错误是什么?

i did not see any configuration in your Spring security to specify the LDAP URL though.我没有在您的 Spring 安全性中看到任何配置来指定 LDAP URL。

try to use the url to specify the LDAP server, otherwise, it by default is using localhost...尝试使用 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=***");
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM