按照4.2.3中的指导一步一步的去作,在登陆界面进行登陆时,报错了,报错信息是LDAP服务器链接不上。java
后来查了一些资源发现还须要加入一些其余的依赖,以下:spring
<dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-ldap</artifactId> </dependency> <dependency> <groupId>com.unboundid</groupId> <artifactId>unboundid-ldapsdk</artifactId> </dependency>
尤为要加入ldapsdk
依赖,有了这个依赖才能起到嵌入的本地的LDAP服务器。对应的配置代码以下:服务器
// LDAP LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder> lapc = auth.ldapAuthentication(); lapc .userSearchBase("ou=people") .userSearchFilter("(uid={0})") .groupSearchBase("ou=groups") .groupSearchFilter("member={0}") .passwordCompare() .passwordEncoder(new LdapShaPasswordEncoder()) .passwordAttribute("userPassword"); lapc .contextSource() .root("dc=tacocloud,dc=com") .ldif("classpath:users.ldif");
除了能使用java代码来进行配置外,还能够在application.properties文件中加入以下的配置:app
spring.ldap.embedded.ldif=classpath:users.ldif spring.ldap.embedded.base-dn=ou=groups,dc=tacocloud,dc=com spring.ldap.embedded.port=33389
最终成功解决!!!ide