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;
  • 相关阅读:
    面试金典——模式匹配
    浅谈C语言中的联合体
    android recovery模式及ROM制作
    模拟键盘输入 : SendMessage, keybd_event, PostKeybdMessage
    在游戏中使用keybd_event的问题
    keybd_event函数用法
    C语言清空输入缓冲区的N种方法对比
    深究“字节对齐”的原因
    字节对齐
    网络安装CentOS 5.3
  • 原文地址:https://www.cnblogs.com/zjk1/p/9438152.html
Copyright © 2011-2022 走看看