2017-05-11 11 views
0

스프링 보안을 사용하여 스프링 LDAP (2.3.1.RELEASE)를 통해 기존 광고에 로그인하려고합니다. (almostly Spring getting started guide에서 가져온) 구성에 대한 책임이 지금까지 내가 가지고 다음 코드 : 내가 생각하는 내가 의도적 .html 중에서 파일을 생략스프링 LDAP 및 스프링 보안을 통해 기존 AD에 연결

<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> 

: 여기

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

내 치어 조각입니다 그들은이 질문에 어떤 역할도하지 않는다. 나는 얻을 수

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 부분을 게시 할 수 있습니까?