2017-05-11 13 views
0

Spring Securityを使用してSpring LDAP(2.3.1.RELEASE)経由で既存のADにログインしようとしています。これまでのところ私は(almostly Spring getting started guideから取られた)の構成を担当し、次のコードを持っている:ここでSpring LDAPとSpringセキュリティを介して既存のADに接続する

@Configuration 
@EnableWebSecurity 
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 
@Override 
protected void configure(HttpSecurity http) throws Exception { 
    http 
     .authorizeRequests() 
     .antMatchers("/", "/home").permitAll() 
     .anyRequest().fullyAuthenticated() 
     .and() 
     .formLogin() 
     .loginPage("/login") 
     .permitAll() 
     .and() 
     .logout() 
     .permitAll(); 
} 

@Override 
public void configure(AuthenticationManagerBuilder auth) throws Exception { 
    authauth 
     .ldapAuthentication() 
     .userDnPatterns("uid={0}") 
     .contextSource(contextSource()) 
     .passwordCompare() 
     .passwordEncoder(new LdapShaPasswordEncoder()) 
     .passwordAttribute("userPassword"); 
} 


@Bean 
public BaseLdapPathContextSource contextSource() { 
    LdapContextSource contextSource = new LdapContextSource(); 
    contextSource.setAnonymousReadOnly(false); 
    contextSource.setBase("dc=foo,dc=bar"); 
    contextSource.setUserDn("[email protected]"); 
    contextSource.setPassword("plainTextPassword"); 
    contextSource.setUrl("ldap://active.directory.address"); 
    return ldapContextSource; 
} 
} 

は私のポンポンスニペットです:

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.5.2.RELEASE</version> 
</parent> 

<dependencies> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-thymeleaf</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-security</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.ldap</groupId> 
     <artifactId>spring-ldap-core</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-ldap</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>com.unboundid</groupId> 
     <artifactId>unboundid-ldapsdk</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-test</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.directory.server</groupId> 
     <artifactId>apacheds-all</artifactId> 
     <version>1.5.5</version> 
    </dependency> 
</dependencies> 

<properties> 
    <java.version>1.8</java.version> 
</properties> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
     </plugin> 
    </plugins> 
</build> 

私が思うように私は意図的に.htmlファイルを省略します彼らはこの質問に何の役割も果たさない。 Atm私は得る

javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903D9, comment: AcceptSecurityContext error, data 52e, v2580 ] 

結果として。例外を検索した後、データ52eはAD_INVALID CREDENTIALSを意味することがわかりました。私は何度も自分の信用証明をチェックして、本当に本当に正しいです。私はMicrosoftのADエクスプローラをダウンロードし、これらの資格情報を使ってADに正常に接続しました。なぜコード経由で動作せず、ADエクスプローラ経由で動作しますか?

答えて

0

いつこのエラーが発生しますか?アプリケーションの起動時またはログインしようとしたとき コンテキストソースに無効な資格情報を入力するとこのエラーが発生します。あなたのパスワードが正しいことが確かな場合は、ベースとuserDNを確認する必要があります。

コンテキストソースで使用しているユーザーがリストされているLDAPツリーまたはLDIFの一部をポストできますか?

関連する問題