ldap的实现单点登录

cas+ldap  连接多哥ldap时大多数引用的都是这个类,但是我中cas -server -supper-ldap3以上的jar中都找不到此类,迷惑了很久于是我找了源码配置文件发现根本不是引用这个类,下面介绍一下cas+ldap连接的两种方式
方式一: 连接单个ldap
[code=html]
在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>
[/code]
方式二: 可连接多ldap
[code=html]
<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>
[/code]

猜你喜欢

转载自www.cnblogs.com/jasonwan/p/10735973.html