您的位置:首页 > 其它

cas+ldap实现单点登录

2014-04-17 10:19 260 查看
cas+ldap 连接多哥ldap时大多数引用的都是这个类,但是我中cas -server -supper-ldap3以上的jar中都找不到此类,迷惑了很久于是我找了源码配置文件发现根本不是引用这个类,下面介绍一下cas+ldap连接的两种方式

方式一: 连接单个ldap

在cas的deployerConfigContext.xml这个文件中找到<bean class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />注释掉添加下面的bean

<bean class="org.jasig.cas.adaptors.ldap.FastBindLdapAuthenticationHandler">

<property name="filter" value="uid=%u,ou=People,o=tcl,c=cn" />

<property name="contextSource" ref="contextSource" />

</bean>

在根节点中添加

<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">

<property name="pooled" value="false"/>

<property name="url" value="ldap://192.168.0.114:389" />

<property name="userDn" value="cn=Manager,o=tcl,c=cn"/>

<property name="password" value="secret"/>

<property name="baseEnvironmentProperties">

<map>

<entry key="com.sun.jndi.ldap.connect.timeout" value="3000" />

<entry key="com.sun.jndi.ldap.read.timeout" value="3000" />

<entry key="java.naming.security.authentication" value="simple" />

</map>

</property>

</bean>


方式二: 可连接多ldap

<bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler">

<property name="filter" value="uid=%u" />

<property name="searchBase" value="ou=People,o=tcl,c=cn" />

<property name="contextSource" ref="contextSource" />

</bean>

根节点添加

<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">

<property name="anonymousReadOnly" value="false" />

<property name="password" value="secret" />

<property name="pooled" value="true" />

<property name="urls">

<list>

<value>ldap://192.168.0.114:389/</value>

</list>

</property>

<property name="userDn" value="cn=Manager,o=tcl,c=cn" />

<property name="baseEnvironmentProperties">

<map>

<!--<entry>

<key><value>java.naming.security.protocol</value></key>

<value>ssl</value>

</entry>-->

<entry>

<key><value>java.naming.security.authentication</value></key>

<value>simple</value>

</entry>

</map>

</property>

</bean>




使用的jar

cas-server-support-ldap-3.4.3.1.jar spring-ldap-1.3.1.RELEASE-all.jar
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: