LDAP连接配置

来源:互联网 发布:淘宝香港代购可靠吗 编辑:程序博客网 时间:2024/06/09 20:18

1.分页查询时配置:

spring ldap配置:

<bean id="contextSource" class="org.springframework.ldap.transaction.compensating.manager.TransactionAwareContextSourceProxy">
        <constructor-arg ref="pooledContextSource"/>
    </bean>

    <bean id="pooledContextSource" class="org.springframework.ldap.pool.factory.MutablePoolingContextSource">
        <property name="contextSource" ref="contextSourceTarget"/>
        <property name="dirContextValidator" ref="dirContextValidator"/>
        <property name="testOnBorrow" value="true"/>
        <property name="testWhileIdle" value="true"/>
        <property name="minIdle" value="0"/>
        <property name="maxIdle" value="8"/>
        <property name="maxActive" value="8"/>
        <property name="maxTotal" value="100"/>
        <property name="maxWait" value="-1"/>
    </bean>
    <bean id="dirContextValidator" class="org.springframework.ldap.pool.validation.DefaultDirContextValidator"/>

<bean id="contextSourceTarget" class="org.springframework.ldap.core.support.LdapContextSource">
        <property name="url" value="ldap://127.0.01:389" />
        <property name="userDn" value="cn=root,dc=testdata" />
        <property name="password" value="12345"/>
        <property name="pooled" value="false" />
    </bean>

<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
        <constructor-arg ref="contextSource" />
    </bean>

<!-- 将ldapTemplate注入到testDataDao-->
    <bean id="testDataDao_LDAP" class="com.talkweb.mainSyn.dal.impl.TestDataDaoImpl">
        <property name="ldapTemplate">
            <ref bean="ldapTemplate" />
        </property>
    </bean>


非分页查询配置2:

<bean id="contextSourceTarget" class="org.springframework.ldap.core.support.LdapContextSource">
        <property name="url" value="ldap://127.0.01:389" />
        <property name="userDn" value="cn=root,dc=testdata" />
        <property name="password" value="12345" />
        <property name="pooled" value="false" />
    </bean>


    <bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
        <constructor-arg ref="contextSourceTarget" />
    </bean>


0 0
原创粉丝点击