zoukankan      html  css  js  c++  java
  • 【spring实战第五版遇到的坑】4.2.3中LDAP内嵌服务器不启动的问题

    按照4.2.3中的指导一步一步的去做,在登录界面进行登录时,报错了,报错信息是LDAP服务器连接不上。

    后来查了一些资源发现还需要加入一些其他的依赖,如下:

    <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文件中加入如下的配置:

    spring.ldap.embedded.ldif=classpath:users.ldif
    spring.ldap.embedded.base-dn=ou=groups,dc=tacocloud,dc=com
    spring.ldap.embedded.port=33389
    

    最终成功解决!!!

  • 相关阅读:
    Jenkins 完成安装环境配置
    Jenkins中文社区的所有镜像地址
    VueX源码分析(3)
    VueX源码分析(2)
    VueX源码分析(1)
    Element表单验证(2)
    Element表单验证(1)
    配置淘宝镜像,不使用怪异的cnpm
    React动态import()
    cnpm 莫名奇妙bug 莫名奇妙的痛
  • 原文地址:https://www.cnblogs.com/zhangfengxian/p/10706975.html
Copyright © 2011-2022 走看看