Central Authentication Service(CAS)之三(LDAP)

LDAP服务器可以装在不同的机器上,CAS通过配置URL来访问它,下面看看CASLDAP服务器结合起来要如何配置:

1.      可以去apache下载最新的apache directory server1.5.5,地址是:http://directory.apache.org/ apache directory server1.5.5可以作为LDAP服务器。下好后安装好。

2.      同样到http://directory.apache.org/ 下载并安装apache directory studio1.4.0

3.      为了简化,可以简单的添加几个用户在默认的ou=system下面, objectClass选择inetOrgPerson。导出的ldif文件:

dn: uid=pt01,ou=system
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: top
cn: user
sn: user
uid: pt01
userPassword:: MTIz

dn: uid=pt02,ou=system
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: top
cn: user
sn: user
uid: pt02
userPassword:: MTIz

 

 

4.      CAS3.3.2 已经没有支持LDAP的类了,所以得添加“Spring-LDAP support package”。“spring-ldap-1.3.0.RELEASE-all.jar 可以在spring的官方网站上找到。

5.      再添加“ cas-server-support-ldap-3.3.2.jar”可以在cas-server-3.3.2/modules目录下找到。

6.      打开目录D:/sso/apps/Tomcat6/webapps/cas/WEB-INF 找到配置文件“deployerConfigContext.xml”,我们要将“SimpleTestUsernamePasswordAuthenticationHandler”替换成“FastBindLdapAuthenticationHandler”,分两步完成:

a)      添加一个contextSource

<bean id="contextSource"

                                  class="org.springframework.ldap.core.support.LdapContextSource">

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

                                  <property name="urls">

                                    <list>

                                      <value>ldap://gbpccmm1.asiapacific.hpqcorp.net:10389</value>

                                    </list>

                                  </property>

                                 

                                    <property name="userDn" value="{cn=bind_user_goes_here}"/>

                                                <property name="password" value="{bind_user_password_goes_here}"/>

                                                <property name="baseEnvironmentProperties">

                                    <map>

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

                                    </map>

                                  </property>

                </bean>

 

b)      替换掉原有的Handler

 

<bean                                                   class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />

 

Replace it with

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

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

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

</bean>

 

7.      重新启动Tomcat,检查log确保没有错误。

8.      用先前设置的用户信息测试一遍,打开https://yejia:8443/cas/login pt02/123或者pt01/123登录看是否能有成功提示。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值