`
张小宇
  • 浏览: 34934 次
  • 性别: Icon_minigender_1
  • 来自: 广州
文章分类
社区版块
存档分类
最新评论

CAS与域控LDAP集成

阅读更多
        各位好,前些时候做了cas与AD集成,也陆陆续续修改丰富了一些博客的内容,写的不周之处大家见谅,多写一些就知道该怎么写了。

        这段时间研究了下CAS SSO与预控LDAP的集成,这里废话不多说,先把标准文档奉上:
        https://wiki.jasig.org/display/CASUM/LDAP

        我的配置也大多按照标准文档配置的,下面依次介绍我个人配置的内容。

        首先,按文档“Including the Handler”要求,配置了pom.xml文件(the default is ${project.home}/cas-server-webapp/pom.xml)。

<dependency>
     <groupId>${project.groupId}</groupId>
     <artifactId>cas-server-support-ldap</artifactId>
     <version>${project.version}</version>
</dependency>


        之后的修改全部在cas-server-webapp/src/main/webapp/WEB-INF/deployerConfigContext.xml这个文件中。

        接下来使用“BindLdapAuthenticationHandler”,具体用的是下面的“Typical Active Directory Configuration”中的方式。

<bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler"
  p:filter="sAMAccountName=%u"
  p:searchBase="cn=Users,dc=example,dc=com"
  p:contextSource-ref="contextSource"
  p:searchContextSource-ref="pooledContextSource"
  p:ignorePartialResultException="true" />


        然后加入"contextSource"与"pooledContextSource"的bean。
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
  <!-- DO NOT enable JNDI pooling for context sources that perform LDAP bind operations. -->
  <property name="pooled" value="false"/>
 
  <!--
    Although multiple URLs may defined, it's strongly recommended to avoid this configuration
    since the implementation attempts hosts in sequence and requires a connection timeout
    prior to attempting the next host, which incurs unacceptable latency on node failure.
    A proper HA setup for LDAP directories should use a single virtual host that maps to multiple
    real hosts using a hardware load balancer.
  -->
  <property name="url" value="ldaps://directory.example.com" />
 
  <!--
    Manager credentials are only required if your directory does not support anonymous searches.
    Never provide these credentials for FastBindLdapAuthenticationHandler since the user's
    credentials are used for the bind operation.
  -->
  <property name="userDn" value="manager"/>
  <property name="password" value="your_manager_password"/>
 
  <!-- Place JNDI environment properties here. -->
  <property name="baseEnvironmentProperties">
    <map>
      <!-- Three seconds is an eternity to users. -->
      <entry key="com.sun.jndi.ldap.connect.timeout" value="3000" />
      <entry key="com.sun.jndi.ldap.read.timeout" value="3000" />
 
      <!-- Explained at http://download.oracle.com/javase/1.3/docs/api/javax/naming/Context.html#SECURITY_AUTHENTICATION -->
      <entry key="java.naming.security.authentication" value="simple" />
    </map>
  </property>
</bean>


<bean id="pooledContextSource"
  class="org.springframework.ldap.pool.factory.PoolingContextSource"
  p:minIdle="${ldap.pool.minIdle}"
  p:maxIdle="${ldap.pool.maxIdle}"
  p:maxActive="${ldap.pool.maxSize}"
  p:maxWait="${ldap.pool.maxWait}"
  p:timeBetweenEvictionRunsMillis="${ldap.pool.evictionPeriod}"
  p:minEvictableIdleTimeMillis="${ldap.pool.idleTime}"
  p:testOnBorrow="${ldap.pool.testOnBorrow}"
  p:testWhileIdle="${ldap.pool.testWhileIdle}"
  p:dirContextValidator-ref="dirContextValidator"
  p:contextSource-ref="contextSource" />
 
<bean id="dirContextValidator"
  class="org.springframework.ldap.pool.validation.DefaultDirContextValidator"
  p:base=""
  p:filter="objectclass=*">
  <property name="searchControls">
    <bean class="javax.naming.directory.SearchControls"
      p:timeLimit="1000"
      p:countLimit="1"
      p:searchScope="0"
      p:returningAttributes="" />
  </property>
</bean>


        最后在“cas.properties”文件中加入连接池的参数值。
ldap.pool.minIdle=3
ldap.pool.maxIdle=5
ldap.pool.maxSize=10
 
# Maximum time in ms to wait for connection to become available
# under pool exhausted condition.
ldap.pool.maxWait=10000
 
# == Evictor configuration ==
 
# Period in ms at which evictor process runs.
ldap.pool.evictionPeriod=600000
 
# Maximum time in ms at which connections can remain idle before
# they become liable to eviction.
ldap.pool.idleTime=1200000
 
# == Connection testing settings ==
 
# Set to true to enable connection liveliness testing on evictor
# process runs.  Probably results in best performance.
ldap.pool.testWhileIdle=true
 
# Set to true to enable connection liveliness testing before every
# request to borrow an object from the pool.
ldap.pool.testOnBorrow=false


        以上都是我用到的标准文档中的内容,值得注意的是两点:

    1、“BindLdapAuthenticationHandler”中的“searchBase”与“contextSource”中的“userDn”里边的内容要写对,可以使用AdExplorer工具连接到AD域中查看,即可得到正确的写法。

    2、我个人需要使用SSL传输,所以标准文档中提到的SSL Considerations要特别注意。需要从域中导出LDAP的证书,然后导入到CAS服务器中,并且使用636端口。

        贴上我在deployerConfigContext.xml使用的配置,仅供参考。
<bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler"
					  p:filter="sAMAccountName=%u"
					  p:searchBase="ou=我的公司名称,dc=XXX,dc=XXXX,dc=com"
					  p:contextSource-ref="contextSource"
					  p:searchContextSource-ref="pooledContextSource"
					  p:ignorePartialResultException="true" />


<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
  <property name="pooled" value="true"/>
  
  <property name="url" value="ldaps://server ip:636/" />
 
  <property name="userDn" value="CN=Administrator,CN=Users,DC=XXX,DC=XXX,DC=com"/>
  <property name="password" value="!QAZ2wsx#EDC"/>
 
  <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>

<bean id="pooledContextSource"
  class="org.springframework.ldap.pool.factory.PoolingContextSource"
  p:minIdle="${ldap.pool.minIdle}"
  p:maxIdle="${ldap.pool.maxIdle}"
  p:maxActive="${ldap.pool.maxSize}"
  p:maxWait="${ldap.pool.maxWait}"
  p:timeBetweenEvictionRunsMillis="${ldap.pool.evictionPeriod}"
  p:minEvictableIdleTimeMillis="${ldap.pool.idleTime}"
  p:testOnBorrow="${ldap.pool.testOnBorrow}"
  p:testWhileIdle="${ldap.pool.testWhileIdle}"
  p:dirContextValidator-ref="dirContextValidator"
  p:contextSource-ref="contextSource" />
 
<bean id="dirContextValidator"
  class="org.springframework.ldap.pool.validation.DefaultDirContextValidator"
  p:base=""
  p:filter="objectclass=*">
  <property name="searchControls">
    <bean class="javax.naming.directory.SearchControls"
      p:timeLimit="1000"
      p:countLimit="1"
      p:searchScope="0"
      p:returningAttributes="" />
  </property>
</bean>


        这样在登录应用系统的时候,会重定向到CAS服务器,显示登陆界面,输入域用户名/密码,即可以域用户身份登录,并达成SSO。
1
1
分享到:
评论
1 楼 xiaobadi 2014-08-22  
你好,请问 p:searchBase和userDn 是什么意思,按照什么规则填写

相关推荐

    confluence的安装以及与LDAP集成

    下面将详细讲解 Confluence 的安装过程和与 LDAP 的集成过程。 Confluence 安装过程 1. 下载并解压 Confluence 软件包,并将其解压到本地目录,例如 D:\confluence\confluence-3.4.8-std。 2. 修改 data 目录指定...

    cas5.1x与ldap服务器整合

    cas5.1.x overlay一体搭建服务端,使用docker搭建centos7部署ldap服务器,压缩包为配置完成的案例

    cas4.1.x 集成 mysql,ldap,redis(session和票据),写了简单的两个客户端 demo

    cas4.1.x 集成 mysql,ldap,redis(session和票据),写了简单的两个客户端 democas4.1.x 集成 mysql,ldap,redis(session和票据),写了简单的两个客户端 democas4.1.x 集成 mysql,ldap,redis(session和票据),写了简单...

    liferay + cas + ldap 集成配置

    标题 "Liferay + CAS + LDAP 集成配置" 涉及到的是在企业级内容管理系统 Liferay 中集成 Central Authentication Service (CAS) 和 Lightweight Directory Access Protocol (LDAP) 的过程。这种集成允许用户通过CAS...

    泛微协同管理ecology系统与LDAP集成手册

    ### 泛微协同管理ecology系统与LDAP集成手册 #### 第一部分:LDAP概述 ##### LDAP目录的优势 在探讨LDAP(轻量级目录访问协议)及其与泛微ecology系统的集成之前,我们首先来了解一下LDAP的一些核心优势。这些...

    使用Delphi连接LDAP服务器

    `TADOConnection`和`TADODataset`等组件是Delphi与数据库交互的基础,但它们并不直接支持LDAP。因此,通常会使用第三方组件如`ldap4delphi`或`Indy`库中的`TIdLDAP`来实现LDAP连接。 在Delphi中连接到LDAP服务器,...

    cas4.1.x集成mysql,ldap,redis(session和票据),写了简单的两个客户端demo

    【CAS 4.1.x 集成 MySQL、LDAP、Redis 实现会话与票据管理】 CAS(Central Authentication Service)是一种广泛使用的单点登录(Single Sign-On,简称SSO)框架,它允许用户通过一个认证过程访问多个应用系统。在这...

    CAS整合LDAP实现单点登录原理及部署

    CAS整合LDAP实现单点登录的原理及部署学习笔记,cas实现单点登录,ldap负责账户管理

    liferay cas ldap 集成配置

    Liferay、CAS(Central Authentication Service)和LDAP(Lightweight Directory Access Protocol)的集成配置是一项复杂的任务,尤其对于那些在IT领域中专注于身份验证和授权管理的研究者来说。以下将详细介绍如何...

    Springboot-LDAP针对AD域控做用户和组织进行同步.zip

    本文将深入探讨如何使用Spring Boot 2.x与LDAP集成,特别是在与Active Directory(AD)域控制器交互,实现用户和组织的同步。 首先,让我们了解Spring Boot 2.x。Spring Boot是Spring框架的一个扩展,它简化了创建...

    CAS_LDAP.rar_CAS SSO_cas ldap_cas openldap_cas_ldap_soa和sso

    在这个场景下,`CAS_LDAP.rar` 文件集合提供了一个关于如何将CAS与OpenLDAP集成以实现SSO和SOA的实践指南。 **CAS (Central Authentication Service)** CAS 是一个开源的、基于Web的单一登录协议服务器,它允许...

    cas集成AD域

    在企业环境中,尤其是在已部署了Active Directory(AD)域服务的情况下,将CAS与AD集成可以实现用户通过一次认证就能访问所有系统,提升用户体验并加强安全性。 AD域是微软Windows Server操作系统中的一个组件,它...

    sonarqube安装与ldap集成

    "SonarQube 安装与 LDAP 集成" SonarQube 是一款流行的代码质量管理工具,通过安装和配置 SonarQube,可以对代码进行静态分析、代码质量检查和可维护性评估等功能。本文将详细介绍 SonarQube 的安装、配置、Sonar ...

    CAS5.3+windows AD域实现单点登录免身份认证.docx

    CAS 服务器可以与多种身份验证系统集成,包括 LDAP、Active Directory 和数据库等。 Windows AD 是微软公司推出的目录服务,用于管理计算机网络中的用户、组和资源。Windows AD 提供了身份验证、授权和目录服务等...

    odoo10-ldap集成

    **Odoo 10 LDAP集成** ...总的来说,Odoo 10与LDAP的集成是提高企业效率、简化用户管理的有效手段。通过正确配置和使用这个模块,企业能够实现统一的用户身份验证,提升管理效率,同时保持数据的安全性。

    单点登录 - CAS【三】 LDAP认证源

    在成功配置CAS与LDAP的集成后,当用户尝试访问受CAS保护的应用时,CAS会将用户名发送到LDAP服务器进行验证。如果验证通过,服务器会返回一个成功的响应,CAS会生成一个票证并将其发送回客户端,客户端再将票证提交给...

    CAS和LDAP整合

    3. **CAS LDAP集成**:在CAS服务器的配置文件中,比如`cas.properties`,添加对LDAP服务器的连接信息,如URL、端口、基础DN(Distinguished Name)以及用户和密码用于连接到LDAP服务器。同时,设置查询过滤器,指定...

    Liferay与LDAP集成

    Liferay与LDAP集成是将Liferay门户与目录服务相结合,实现单点登录、用户身份验证和用户数据同步等功能,提升企业级应用的安全性和用户体验。 OpenLDAP是LDAP协议的开源实现,包括slapd(LDAP服务守护进程)、...

Global site tag (gtag.js) - Google Analytics