Liferay 的单点登陆绝对是个难啃的骨头,更况且网上能搜到的基本都是些滥竽充数的文章,很不负责任。html
因而在本身搭通单点登陆一条线以后,决定整理下思路并写出来,但愿各位能别重蹈覆辙。linux
本文不介绍概念。仅仅注重实现数据库
软件版本号:apache
Liferay : 6.1.1 CE GA2 OpenLdap for Windows :openldap-2.4.38-x86 Apache Directory Studio : Apache Directory Studio 2.0.0-M3 CAS : cas-server-3.5.2 Windows : 7 x64
再也不讲述 LDAP 概念,仅仅需知道 OpenLDAP 是 LDAP 协议的几个主流实现之中的一个,重点是介绍怎样在 windows 平台上安装和配置 OpenLDAP。windows
openLDAP官方站点:http://www.openldap.org/
openLDAP官网仅仅提供了linux平台的相关安装文件,windows平台的安装包可以到下面一些站点下载:
http://www.userbooster.de/download/openldap-for-windows.aspx
http://sourceforge.jp/projects/openldapwin32/releases/
http://sourceforge.net/projects/openldapwindows/files/
app
include ../etc/openldap/schema/core.schema include ../etc/openldap/schema/cosine.schema include ../etc/openldap/schema/inetorgperson.schema pidfile ../var/run/slapd.pid loglevel -1 moduleload back_bdb.la database bdb suffix "dc=example, dc=com" rootdn "cn=jimbob, dc=example, dc=com" rootpw dirtysecret directory ../var/openldap-data # Indices to maintain for this directory # unique id so equality match only index uid eq # allows general searching on commonname, givenname and email index cn,gn,mail eq,sub # allows multiple variants on surname searching index sn eq,sub # sub above includes subintial,subany,subfinal # optimise department searches index ou eq # if searches will include objectClass uncomment following # index objectClass eq # shows use of default index parameter index default eq,sub # indices missing - uses default eq,sub index telephonenumber # other database parameters # read more in slapd.conf reference section cachesize 10000 checkpoint 128 15
这个安装版本号中。不需要经过命令行启动,開始菜单里找到 OpenLDAP。并启动ide
通常教程到这里都会提示需要新建个 .ldif 文件,用来加入用户或者组织,事实上刚開始大可没必要纠结于这个文件以及里面的语法。因为全然可以使用 LDAP 可视化工具完毕相同的工做。工具
但毕竟写文档。这部分仍是得写。ui
DIT 结构 – 例如如下图,可以理解为LDAP 的结构文件夹,就比方 Java Web应用的文件夹。this
dn: dc=example,dc=com dc: example description: text whatever you want for description objectClass: dcObject objectClass: organization o: Example, Inc. dn: ou=people, dc=example,dc=com ou: people description: All people in organisation objectclass: organizationalunit dn: cn=Robert Smith,ou=people,dc=example,dc=com objectclass: inetOrgPerson cn: Robert Smith sn: smith uid: rjsmith userpassword: rJsmitH mail: rsmith@example.com description: swell guy ou: Human Resources
在E:\OpenLDAP\bin文件夹下输入下面指令用来导入 LDIF 文件。为何要到这个文件夹。因为这个文件夹底下有ldapadd.exe,否则使用 ldapadd 指令会提示提示:’ldapadd’ 不是内部或外部命令。也不是可执行的程序或批处理文件
ldapadd -x -D "cn=jimbob,dc=example,dc=com" -f ./mydemo.ldif -w dirtysecret
接下来经过下面search 指令确认是否导入成功
ldapsearch -x -b "dc=example,dc=com" "(objectclass=*)"
安装以及配置步骤可以參考官方文档https://directory.apache.org/studio/users-guide/ldap_browser/gettingstarted_download_install.html
左下 Connection 区域点击右键加入 Connection。
注意 OpenLdap 的 Port 为 389。
Users
User Mapping – 用来映射 LDAP 内 user 属性与 Liferay 内user属性
Groups – 相应于 LDAP 里的 group
Export – 这个必须配置,否则没法将 Liferay 用户处处到 LDAP server,致使配置完毕以后, Liferay 用户反而不能成功登陆