zoukankan      html  css  js  c++  java
  • 集成spring-ldap

    1.pom文件增加

      <dependency>
                <groupId>org.springframework.ldap</groupId>
                <artifactId>spring-ldap-core</artifactId>
                <version>2.3.2.RELEASE</version>
            </dependency>

    2.spring配置文件增加

    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:ldap="http://www.springframework.org/schema/ldap"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/ldap
    http://www.springframework.org/schema/ldap/spring-ldap.xsd"
    >
        <bean id="contextSource"    
            class="org.springframework.ldap.core.support.LdapContextSource">    
            <property name="url" value="ldap://192.168.80.123:389" />    
            <property name="base" value="dc=kpzc,dc=local" />    
            <property name="userDn" value="admin@kpzc.local" />    
            <property name="password" value="kpzc" />  
        </bean>  
          
        <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">    
            <constructor-arg ref="contextSource" />  
        </bean>

    url 账号 密码 我是固定写死的 也可配置在properties文件中

    3.启动项目会出现


    17:02:24.853 [main] DEBUG o.s.l.c.s.AbstractContextSource - AuthenticationSource not set - using default implementation
    17:02:24.854 [main] DEBUG o.s.l.c.s.AbstractContextSource - Not using LDAP pooling
    17:02:24.857 [main] DEBUG o.s.l.c.s.AbstractContextSource - Trying provider Urls: ldap://192.168.80.123:389/dc=kpzc,dc=local

    即可使用Autowired注解了

    @Autowired
    private LdapTemplate ldapTemplate;
  • 相关阅读:
    react redux
    react 路由 react-router@3.2.1
    react 生命周期
    重载 UINavigationController 设置左侧返回按钮的文字为图片
    使用 SQLiteManager 操作 sqlite3 数据库
    使用 DES 算法对数据加密
    使用 Reachability 获取网络状态
    NSPredicate 的使用(持续更新)
    使用开源库 SDWebImage 异步下载缓存图片(持续更新)
    Grand Central Dispatch (GCD)
  • 原文地址:https://www.cnblogs.com/zjk1/p/9438152.html
Copyright © 2011-2022 走看看