2023年6月21日发(作者:)
ldap统⼀认证架构⽅案及实现指南(⼀)⼀、ldap⽬录服务介绍什么是⽬录服务? ⽬录是⼀类为了浏览和搜索数据⽽设计的特殊的数据库。例如,为⼈所熟知的微软公司的活动⽬录(active directory)就是⽬录数据库的⼀种。⽬录服务是按照树状形式存储信息的,⽬录包含基于属性的描述性信息,并且⽀持⾼级的过滤功能。什么是LDAP? LDAP是轻量⽬录访问协议,英⽂全称是Lightweight Directory Access Protocol,⼀般都简称为LDAP。它是基于X.500标准的,但是简单多了并且可以根据需要定制。与X.500不同,LDAP⽀持TCP/IP,这对访问Internet是必须的。LDAP的核⼼规范在RFC中都有定义,所有与LDAP相关的RFC都可以在LDAPman RFC⽹页中找到。1、LDAP模型和扩展框架信息模型:确定LDAP⽬录中信息的格式和字符集,如何表⽰⽬录信息(定义对象类、属性、匹配规则和语法等模式)命名空间:信息组织⽅式-⽬录信息树DIT,以DN和RDN为基础的命名⽅式,以及LDAP信息的Internet表⽰⽅式功能模型:执⾏操作的通信协议以及在客户端进⾏这些操作的API接⼝安全框架:保证⽬录中信息的安全,多种认证⽅式,以及与TLS结合的通信保护框架LDAP扩展框架:基于控制和扩展操纵的LDAP扩展框架2、LDAP的存储⽅式 LDAP以树型结构存储,具体信息存储在条⽬的数据结构中。⼀个⽬录信息树由若⼲条⽬组成,⼀个条⽬⼀个对象,每个条⽬具有唯⼀的标识名DN,并由多个属性组成,每个属性对应⼀个或多个值。 LDAP⽬录服务器是通过⽬录数据库来存储⽹络信息以提供⽬录服务的,⽬录信息树及其相关概念构成了LDAP协议的信息模型。注:dc(domain component)表⽰域名的部分,其格式是将完整的域名分为⼏部分;uid表⽰⽤户ID;ou(organization unit)表⽰组织单位;cn(common name)表⽰公共名称;关键字sn(surname)表⽰姓;dn(distinguished name)表⽰唯⼀辨别名,rdn(relative dn)表⽰相对辨别名;关键字c(country)表⽰国家;关键字o(organization)表⽰组织名。⼆、深⼊认识LDAP1、LDAP的⼏种基本模型 LDAP的体系结构由信息模型、命名模型、功能模型以及安全模型4种基本模型组成。其中,信息模型描述LDAP的信息表⽰⽅式;命名模型描述LDAP的数据如何组织;功能模型描述LDAP的数据操作访问⽅式;安全模型描述LDAP的安全机制。(1)信息模型 LDAP信息模型定义了能够在⽬录中存储的数据类型和基本的信息单位。LDAP中的信息是以树状结构组织,在树状信息中的基本数据单位是条⽬(即关于对象的信息集合),⽽每个条⽬由属性构成,属性中存储属性值,每个属性类型⼜有对应的语法和匹配规则。通常,条⽬中的信息说明真实世界的对象。(2)命名模型 在LDAP中每个条⽬均有⾃⼰的DN和RDN(Relative Distinguished Name,相对标识名),其中DN是该条⽬在整个树中的唯⼀名称标识,⽽RDN是条⽬在⽗节点下的唯⼀名称标识。 dn:每个条⽬的唯⼀标识符,如上图中linuxprobe的dn值是: cn=linuxprobe,ou=marketing,ou=people,dc=mydomain,dc=org rdn:⼀般为dn值中最左侧的部分,如上图中linuxprobe的rdn值是: cn=linuxprobe base DN:此为基准DN值,表⽰顶层的根部,上图中的base DN值是: dc=mydomain,dc=org(3)功能模型说明了能够使⽤LDAP协议对⽬录执⾏的操作,共4类10中操作。更新类操作:添加条⽬、删除条⽬、修改条⽬、修改条⽬名查询类操作:搜索、⽐较认证类操作:绑定、解绑定其他操作:放弃和扩展操作注:除扩展操作,其余9种是LDAP的标准操作,扩展操作是LDAP中为了增加新的功能所提供的⼀种标准的扩展框架。(4)安全模型LDAP的安全模型主要通过⾝份认证、安全通道和访问控制来实现。⾝份认证: 匿名认证:适⽤于没有数据安全问题且不涉及访问权限的完全公开⽅式 基本认证:通过⽤分辨名(DN)和密码进⾏⾝份识别,密码识别有分为简单密码和摘要密码认证 SASL(Simple Authentication and Secure Layer)认证:在SSL和TLS安全通道基础上进⾏的⾝份认证,包括数字证书的认证 通信安全在LDAP中提供了基于SSL/TLS的通信安全保障。SSL/TLS是基于PKI信息安全技术的,是⽬前Internet上⼴泛采⽤的安全服务。TLS服务可以被LDAP通过StartTLS⽅式启动,该服务既可以提供通信中的数据保密性、完整性保护,也可以实现客户端⾝份和服务器端⾝份的双向验证。访问控制的标准:⽬前并⽆访问控制的标准,但LDAP的访问控制⾮常灵活和丰富。在LDAP中访问控制是通过访问控制策略语句来实现的,⽽RDBS和应⽤系统是通过访问控制列表来实现的。2、LDAP的应⽤领域LDAP被⼴泛⽤于基础性、关键性信息的管理。信息安全类:数字证书管理、授权管理、单点登录⽹络资源管理类:MAIL系统、DNS系统、⽹络⽤户管理、电话号码簿。科学计算类:DCE(Distributed Computing Environment,分布式计算环境),UDDI(Universal Description,Discovery andIntegration,统⼀描述,发现和集成协议)电⼦政务资源管理:内⽹组织信息服务,电⼦政务⽬录体系,⼈⼝基础库,法⼈基础库LDAP之所以能⼴泛⽤于管理⽤户信息、⽹络资源信息等,是由于LDAP具有⾼效率的查询,树状的信息管理模式,分布式的部署框架以及细致灵活的访问控制的特点。三、OpenLDAP环境搭建1.环境准备[root@ldap ~]# cat /etc/redhat-release
CentOS release 6.8 (Final)[root@ldap ~]# uname -6.x86_64[root@ldap ~]# 配置rsyslog记录ldap服务⽇志:[root@ldap openldap]# cp /etc/ /etc/[root@ldap openldap]# echo "record by linuxzkq 2016/11/2" >>/etc/[root@ldap openldap]# echo "local4.* /var/log/">> /etc/
[root@ldap openldap]# tail -2 /etc/cord by linuxzkq 2016/11/2local4.* /var/log/[root@ldap openldap]# /etc/init.d/rsyslog restartShutting down system logger: [ OK ]Starting system logger: [ OK ][root@ldap openldap]# ll /var/log/
-rw-------. 1 root root 0 Nov 2 23:13 /var/log/配置LDAP数据库路径:[root@ldap openldap]# grep "directory" |grep -v "#"directory /var/lib/ldap[root@ldap openldap]# cp /usr/share/openldap-servers/DB_e /var/lib/ldap/DB_CONFIG[root@ldap openldap]# ll /var/lib/ldap
total 4-rw-r--r--. 1 root root 845 Nov 2 23:17 DB_CONFIG[root@ldap openldap]# chown ldap:ldap /var/lib/ldap/DB_CONFIG[root@ldap openldap]# chmod 700 /var/lib/ldap/DB_CONFIG[root@ldap openldap]# ll /var/lib/ldap total 4-rwx------. 1 ldap ldap 845 Nov 2 23:17 DB_CONFIG[root@ldap openldap]# egrep -v "#|^$" /var/lib/ldap/DB_CONFIGset_cachesize 0 268435456 1set_lg_regionmax 262144set_lg_bsize 2097152[root@ldap openldap]# slaptest -u //测试配置⽂件是否配置成功[root@ldap openldap]# slaptest -u //测试配置⽂件是否配置成功config file testing succeeded最终LDAP完整配置⽂件:[root@ldap openldap]# egrep -v "^$|^.*#" clude /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/allow bind_v2pidfile /var/run/openldap/sfile /var/run/openldap/SCACertificatePath /etc/openldap/certsTLSCertificateFile ""OpenLDAP Server""TLSCertificateKeyFile /etc/openldap/certs/password access to * by self write by anonymous auth by * readbase bdbsuffix "dc=etiantian,dc=org"rootdn "cn=admin,dc=etiantian,dc=org"directory /var/lib/ldapindex objectClass eq,presindex ou,cn,mail,surname,givenname eq,pres,subindex uidNumber,gidNumber,loginShell eq,presindex uid,memberUid eq,pres,subindex nisMapName,nisMapEntry eq,pres,subrootpw {SSHA}mDsZ2A7nq6PCQ9CQmLTZThIDqHbxvHT3loglevel 296cachesize 1000checkpoint 2048 10[root@ldap openldap]# diff 98,108c98,101< database config< access to *< by ="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage< by * none<
< # enable server status monitoring (cn=monitor)< database monitor< access to *< by ="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read< by ="cn=Manager,dc=my-domain,dc=com" read< by * none---> access to *> by self write> by anonymous auth> by anonymous auth> by * read114,117c107,116< database bdb< suffix "dc=my-domain,dc=com"< checkpoint 1024 15< rootdn "cn=Manager,dc=my-domain,dc=com"---> #database bdb> #suffix "dc=my-domain,dc=com"> #checkpoint 1024 15> #rootdn "cn=Manager,dc=my-domain,dc=com"> #add start by linuxzkq 2016/11/2> base bdb> suffix "dc=etiantian,dc=org"> rootdn "cn=admin,dc=etiantian,dc=org"> #add end by linuxzkq 2016/11/2>
141a141,145> #add start by linuxzkq 2016/11/2> loglevel 296> cachesize 1000> checkpoint 2048 10> #add end by linuxzkq 2016/11/2[root@ldap openldap]# /etc/init.d/slapd startStarting slapd: [ OK ][root@ldap openldap]# netstat -tunlp|grep slapdtcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN 3002/slapd
tcp 0 0 :::389 :::* LISTEN 3002/slapd
[root@ldap openldap]# lsof -i:389COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEslapd 3002 ldap 7u IPv4 22382 0t0 TCP *:ldap (LISTEN)slapd 3002 ldap 8u IPv6 22383 0t0 TCP *:ldap (LISTEN)[root@ldap openldap]# ps -ef|grep ldap|grep -v grepldap 3002 1 0 23:31 ? 00:00:00 /usr/sbin/slapd -h ldap:/// ldapi:/// -u ldap[root@ldap openldap]# chkconfig slapd on[root@ldap openldap]# chkconfig --list slapdslapd 0:off 1:off 2:on 3:on 4:o5:on 6:off查看ldap master数据库:[root@ldap openldap]# ldapldapadd ldapmodify ldapurlldapcompare ldapmodrdn ldapwhoamildapdelete ldappasswd
ldapexop ldapsearch
[root@ldap openldap]# ldapsearch -LLL -W -x -H ldap:// -D "cn=admin,dc=etiantian,dc=org" -b"dc=etiantian,dc=org" "(uid=*)"Enter LDAP Password:
ldap_bind: Invalid credentials (49) //查询ldap数据库报错,密码对也连接不上。出错,解决ldap2.3和2.4配置冲突问题,解决⽅法如下:[root@ldap openldap]# ll /etc/openldap/slapd.d/total 8drwx------. 3 ldap ldap 4096 Nov 1 23:46 cn=config-rw-------. 1 ldap ldap 1281 Nov 1 23:46 cn=[root@ldap openldap]# rm -rf /etc/openldap/slapd.d/*[root@ldap openldap]# slaptest -f /etc/openldap/ -F /etc/openldap/slapd.d581a0d14 bdb_monitor_db_open: monitoring disabled; configure monitor database to enableconfig file testing succeeded[root@ldap openldap]# ll /etc/openldap/slapd.d total 8drwxr-x---. 3 root root 4096 Nov 2 23:59 cn=config-rw-------. 1 root root 1301 Nov 2 23:59 cn=[root@ldap openldap]# /etc/init.d/slapd restartStopping slapd: [ OK ]Checking configuration files for slapd: [FAILED]581a0daf ldif_read_file: Permission denied for "/etc/openldap/slapd.d/cn="slaptest: bad configuration file![root@ldap openldap]# chown -R /etc/openldap/slapd.d/[root@ldap openldap]# ll /etc/openldap/slapd.d
total 8drwxr-x---. 3 ldap ldap 4096 Nov 2 23:59 cn=config-rw-------. 1 ldap ldap 1301 Nov 2 23:59 cn=[root@ldap openldap]# /etc/init.d/slapd restart
Stopping slapd: [FAILED]Starting slapd: [ OK ][root@ldap openldap]# lsof -i:389COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEslapd 3186 ldap 7u IPv4 23490 0t0 TCP *:ldap (LISTEN)slapd 3186 ldap 8u IPv6 23491 0t0 TCP *:ldap (LISTEN)[root@ldap openldap]# ldapsearch -LLL -W -x -H ldap:// -D "cn=admin,dc=etiantian,dc=org" -b"dc=etiantian,dc=org" "(uid=*)"Enter LDAP Password:
No such object (32)⾄此问题解决。查询LDAP的⽬录条⽬,介绍⼀下ldapsearch命令,具体可以使⽤man帮助⼿册查看。 -b:指定查找的节点 -D:指定查找的DN -x:使⽤简单认证 -W:查询是输⼊密码,或者使⽤-w password -h:OpenLDAP的主机地址,可以使⽤IP或者域名 -H:使⽤LDAP服务器的URI地址进⾏操作为ldap master数据库添加数据的⽅法:为ldap添加⽤户数据,有四种⽅法,分别如下,我们选择第四种⽅法进⾏试验。 1)可以直接修改slapd.d⽬录下⾯的数据⽂件,好处是不⽤重启服务,直接⽣效; 1)可以直接修改slapd.d⽬录下⾯的数据⽂件,好处是不⽤重启服务,直接⽣效; 2)安装开源⼯具migrationtools来⽣成ldif⽂件,并通过ldapadd来添加; 3)安装ldap 客户端,这种⽅法最为简单; 4)直接编辑ldif⽂件,然后通过ldapadd添加。 ⾸先我们⼿动编辑⽂件,直接复制好像会因为格式有问题。每个条⽬之间有个空格,直接复制过去会有点问题,需要你把每个条⽬之间“空⾏”的第⼀个空格删除⼀下。[root@ldap openldap]# vi : dc=etiantian,dc=orgobjectClass: organizationobjectClass: dcObjectdc: etiantiano: etiantiandn: ou=People,dc=etiantian,dc=orgobjectClass: organizationalUnitou: Peopledn: ou=group,dc=etiantian,dc=orgobjectClass: organizationalUnitou: group开始导⼊数据并初始化ldap测试数据:[root@ldap openldap]# ldapadd -x -H ldap:// -D "cn=admin,dc=etiantian,dc=org" -W -f
Enter LDAP Password:
adding new entry "dc=etiantian,dc=org"adding new entry "ou=People,dc=etiantian,dc=org"adding new entry "ou=group,dc=etiantian,dc=org"查询导⼊的结果:[root@ldap openldap]# ldapsearch -LLL -x -H ldap:// -D "cn=admin,dc=etiantian,dc=org" -b"dc=etiantian,dc=org" -w 123456
dn: dc=etiantian,dc=orgobjectClass: organizationobjectClass: dcObjectdc: etiantiano: etiantiandn: ou=People,dc=etiantian,dc=orgobjectClass: organizationalUnitou: Peopledn: ou=group,dc=etiantian,dc=orgobjectClass: organizationalUnitou: group查看密码验证机制列表,输⼊:[root@ldap sadoc]# saslsasl2-sample-client saslauthdsasl2-sample-server sasldblistusers2sasl2-shared-mechlist saslpasswd2[root@ldap sadoc]# saslauthd -vsaslauthd 2.1.23authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap[root@ldap sadoc]# grep -i "mech" /etc/sysconfig/saslauthd
# Mechanism to use when checking passwords. Run "saslauthd -v" to get a list# of which mechanism your installation was compiled with the ablity to =pam# Options sent to the saslauthd. If the MECH is other than "pam" uncomment the next line.[root@ldap sadoc]# sed -i 's#MECH=pam#MECH=shadow#g' /etc/sysconfig/saslauthd[root@ldap sadoc]# grep -i "mech" /etc/sysconfig/saslauthd|grep -v "#"
MECH=shadow[root@ldap sadoc]# /etc/init.d/saslauthd restartStopping saslauthd: [FAILED]Starting saslauthd: [ OK ][root@ldap sadoc]# ps -ef|grep saslroot 3817 1 0 21:49 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadowroot 3819 3817 0 21:49 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadowroot 3820 3817 0 21:49 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadowroot 3821 3817 0 21:49 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadowroot 3822 3817 0 21:49 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadowroot 3824 3717 0 21:49 pts/0 00:00:00 grep sasl测试saslauthd进程的认证功能:[root@ldap sadoc]# testsaslauthd -uadmin -p1234560: NO "authentication failed" //失败,因为系统⽤户⾥⾯没有这个⽤户,所以失败,下⾯添加⽤户。[root@ldap sadoc]# grep "admin" /etc/passwd[root@ldap sadoc]# id adminid: admin: No such user[root@ldap sadoc]# useradd admin[root@ldap sadoc]# passwd adminChanging password for user password:
BAD PASSWORD: it is too simplistic/systematicBAD PASSWORD: is too simpleRetype new password: //设置密码为上⾯的"123456"passwd: all authentication tokens updated successfully.[root@ldap sadoc]# testsaslauthd -uadmin -p1234560: OK "Success."[root@ldap sadoc]# testsaslauthd -utest1 -p1234560: NO "authentication failed" //使⽤LDAP的⽤户测试,认证失败,说明⽬前还不⽀持LDAP的⽤户。测试通过LDAP进⾏验证:[root@ldap sadoc]# man saslauthd //man配置⽂件,输⼊"/ldap"搜索ldap相关配置。SASLAUTHD(8) BSD System Manager’s Manual SASLAUTHD(8)NAME saslauthd - sasl authentication serverSYNOPSIS saslauthd -a authmech [-Tvdchlr] [-O option] [-m mux_path] [-n threads] [-s size] [-t timeout]DESCRIPTION saslauthd is a daemon ldap (All platforms that support OpenLDAP 2.0 or higher) Authenticate against an ldap server. The ldap con- figuration parameters are read from /etc/saslau- . The location of this file can be changed with the -O parameter. See the LDAP_SASLAUTHD file included with the distribu- tion for the list of avail- able parameters.[root@ldap sadoc]# history|grep sed 8 sed -i 's/keepcache=0/keepcache=1/g' /etc/ 275 slappasswd -s 123456|sed -e "s#{SSHA}#rootpwt{SSHA}#g" >> 383 sed -i 's#cn=Manager#cn=amin#g' 384 sed -i 's#dc=my-domain#dc=etiantian#g' 385 sed -i 's#dc=com#dc=org#g' 387 sed -i 's#cn=amin#cn=admin#g' 411 sed -i 's#MECH=pam#MECH=shadow#g' /etc/sysconfig/saslauthd 426 history|grep sed[root@ldap sadoc]# sed -i 's#MECH=shadow#MECH=ldap#g' /etc/sysconfig/saslauthd[root@ldap sadoc]# grep -i "mech" /etc/sysconfig/saslauthd|grep -v "#"
MECH=ldap[root@ldap sadoc]# /etc/init.d/saslauthd restartStopping saslauthd: [ OK ]Starting saslauthd: [ OK ][root@ldap sadoc]# testsaslauthd -utest1 -p1234560: NO "authentication failed"[root@ldap sadoc]# testsaslauthd -uadmin -p1234560: NO "authentication failed"再次使⽤系统⽤户admin和ldap⽤户test1认证都失败了。配置saslauthd连接LDAP的连接信息:[root@ldap sadoc]# vi /etc/
ldap_servers: ldap:///#ldap_uri: ldap:///#ldap_version: 3#ldap_start_tls: 0ldap_bind_dn: cn=admin,dc=etiantian,dc=orgldap_bind_pw: 123456ldap_search_base: ou=People,dc=etiantian,dc=orgldap_search_base: ou=People,dc=etiantian,dc=orgldap_filter: uid=%U#ldap_filter: mail=%U@p_password_attr: userPassword#ldap_sasl: 0[root@ldap sadoc]# /etc/init.d/saslauthd restartStopping saslauthd: [ OK ]Starting saslauthd: [ OK ][root@ldap sadoc]# testsaslauthd -u oldboy -p 1234560: OK "Success." //ldap⽤户认证成功[root@ldap sadoc]# testsaslauthd -u test1 -p 123456
0: OK "Success." //ldap⽤户认证成功[root@ldap sadoc]# testsaslauthd -u admin -p 1234560: NO "authentication failed" //系统⽤户admin认证失败开发脚本⼀键安装svn服务并测试成功:[root@client ~]# vi auto_install_#!/bin/sh#the scripts is auto_install_svn script command#date:2016-11-04#author:linuxzkq#mail:1729294227@#version:v1.0#yum install svnyum -y install subversion#set "keepcache=1"sed -i 's/keepcache=0/keepcache=1/g' /etc/ep "keepcache" /etc/#create svn svndata and svnpasswd directorymkdir -p /application/svndatamkdir -p /application/svnpasswd#start svnsvnserve -d -r /application/svndata/ps -ef| grep svn|grep -v grepnetstat -tunlp|grep 3690#create svn Projectsvnadmin create /application/svndata/sadoc#start config svncd /application/svndata/sadoc/conf//bin/cp -i 's/# anon-access = read/anon-access = none/g' d -i 's/# auth-access = write/auth-access = write/g' d -i 's@# password-db = passwd@password-db = /application/svnpasswd/passwd@g' d -i 's@# authz-db = authz@authz-db = /application/svnpasswd/authz@g' #start config svn passwd and authz/bin/cp authz passwd /application/svnpasswd/chmod 700 /application/svnpasswd/*cat >>/application/svnpasswd/passwd< EOFcat >>/application/svnpasswd/authz< * = EOF#restart svnpkill svnservesleep 3svnserve -d -r /application/svndata/#test local fileecho "please exec the cmd bellow:"echo "svn checkout svn://192.168.0.110/sadoc /opt --username=linuxzkq --password=123456"sleep 600配置svn通过LDAP验证并且授权:[root@ldap ~]# ll /etc/sasl2/total 4-rw-r--r--. 1 root root 49 Feb 20 2014 [root@ldap ~]# vi /etc/sasl2/check_method: saslauthdmech_list: PLAIN LOGIN[root@ldap ~]# cp /application/svndata/sadoc/conf/ /application/svndata/sadoc/conf/[root@ldap ~]# sed -i 's@# use-sasl = true@use-sasl = true@g' /application/svndata/sadoc/conf/[root@ldap ~]# grep "sasl" /application/svndata/sadoc/conf/[sasl]use-sasl = true[root@ldap ~]# vi /application/svnpasswd/authz在[groups]标签下加⼊:ldap = test1,oldboy在[sadoc:/]标签下加⼊:@ldap = rw特别注意:加⼊以上内容,给予ldap⽤户访问svn版本库的权限。[root@ldap ~]# pkill svnserve[root@ldap ~]# svnserve -d -r /application/svndata[root@ldap ~]# netstat -tunlp|grep 3690tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 1870/svnserve[root@ldap ~]# svn checkout svn://192.168.0.111/sadoc /opt --username=oldboy --password=123456A /opt/aA /opt/ /opt/bA /opt/cA /opt/dA /opt/ /opt/ /opt/新建 Microsoft Access 数据库.accdbA /opt/cked out revision d out revision 48.[root@ldap ~]# svn ls svn://192.168.0.111/sadoc --username=test1 --password=123456 d通过以上结果,可以看出ldap⽤户oldboy访问svn版本库正常。svn通过ldap验证的总结:1.配置成功saslauthd,前提条件;2.配置/etc/sasl2/;[root@ldap ~]# vi /etc/sasl2/check_method: saslauthdmech_list: PLAIN LOGIN3.配置好svn服务,并且开启sasl⽀持,重启svn;[root@ldap ~]# grep "sasl" /application/svndata/sadoc/conf/[sasl]use-sasl = true4.配置authz授权ldap⽤户访问相关项⽬的权限;[root@ldap ~]# vi /application/svnpasswd/authz在[groups]标签下加⼊:ldap = test1,oldboy在[sadoc:/]标签下加⼊:@ldap = rw5.测试访问linux或win32[root@ldap ~]# svn ls svn://192.168.0.111/sadoc --username=test1 --password=123456 2023年6月21日发(作者:) ldap统⼀认证架构⽅案及实现指南(⼀)⼀、ldap⽬录服务介绍什么是⽬录服务? ⽬录是⼀类为了浏览和搜索数据⽽设计的特殊的数据库。例如,为⼈所熟知的微软公司的活动⽬录(active directory)就是⽬录数据库的⼀种。⽬录服务是按照树状形式存储信息的,⽬录包含基于属性的描述性信息,并且⽀持⾼级的过滤功能。什么是LDAP? LDAP是轻量⽬录访问协议,英⽂全称是Lightweight Directory Access Protocol,⼀般都简称为LDAP。它是基于X.500标准的,但是简单多了并且可以根据需要定制。与X.500不同,LDAP⽀持TCP/IP,这对访问Internet是必须的。LDAP的核⼼规范在RFC中都有定义,所有与LDAP相关的RFC都可以在LDAPman RFC⽹页中找到。1、LDAP模型和扩展框架信息模型:确定LDAP⽬录中信息的格式和字符集,如何表⽰⽬录信息(定义对象类、属性、匹配规则和语法等模式)命名空间:信息组织⽅式-⽬录信息树DIT,以DN和RDN为基础的命名⽅式,以及LDAP信息的Internet表⽰⽅式功能模型:执⾏操作的通信协议以及在客户端进⾏这些操作的API接⼝安全框架:保证⽬录中信息的安全,多种认证⽅式,以及与TLS结合的通信保护框架LDAP扩展框架:基于控制和扩展操纵的LDAP扩展框架2、LDAP的存储⽅式 LDAP以树型结构存储,具体信息存储在条⽬的数据结构中。⼀个⽬录信息树由若⼲条⽬组成,⼀个条⽬⼀个对象,每个条⽬具有唯⼀的标识名DN,并由多个属性组成,每个属性对应⼀个或多个值。 LDAP⽬录服务器是通过⽬录数据库来存储⽹络信息以提供⽬录服务的,⽬录信息树及其相关概念构成了LDAP协议的信息模型。注:dc(domain component)表⽰域名的部分,其格式是将完整的域名分为⼏部分;uid表⽰⽤户ID;ou(organization unit)表⽰组织单位;cn(common name)表⽰公共名称;关键字sn(surname)表⽰姓;dn(distinguished name)表⽰唯⼀辨别名,rdn(relative dn)表⽰相对辨别名;关键字c(country)表⽰国家;关键字o(organization)表⽰组织名。⼆、深⼊认识LDAP1、LDAP的⼏种基本模型 LDAP的体系结构由信息模型、命名模型、功能模型以及安全模型4种基本模型组成。其中,信息模型描述LDAP的信息表⽰⽅式;命名模型描述LDAP的数据如何组织;功能模型描述LDAP的数据操作访问⽅式;安全模型描述LDAP的安全机制。(1)信息模型 LDAP信息模型定义了能够在⽬录中存储的数据类型和基本的信息单位。LDAP中的信息是以树状结构组织,在树状信息中的基本数据单位是条⽬(即关于对象的信息集合),⽽每个条⽬由属性构成,属性中存储属性值,每个属性类型⼜有对应的语法和匹配规则。通常,条⽬中的信息说明真实世界的对象。(2)命名模型 在LDAP中每个条⽬均有⾃⼰的DN和RDN(Relative Distinguished Name,相对标识名),其中DN是该条⽬在整个树中的唯⼀名称标识,⽽RDN是条⽬在⽗节点下的唯⼀名称标识。 dn:每个条⽬的唯⼀标识符,如上图中linuxprobe的dn值是: cn=linuxprobe,ou=marketing,ou=people,dc=mydomain,dc=org rdn:⼀般为dn值中最左侧的部分,如上图中linuxprobe的rdn值是: cn=linuxprobe base DN:此为基准DN值,表⽰顶层的根部,上图中的base DN值是: dc=mydomain,dc=org(3)功能模型说明了能够使⽤LDAP协议对⽬录执⾏的操作,共4类10中操作。更新类操作:添加条⽬、删除条⽬、修改条⽬、修改条⽬名查询类操作:搜索、⽐较认证类操作:绑定、解绑定其他操作:放弃和扩展操作注:除扩展操作,其余9种是LDAP的标准操作,扩展操作是LDAP中为了增加新的功能所提供的⼀种标准的扩展框架。(4)安全模型LDAP的安全模型主要通过⾝份认证、安全通道和访问控制来实现。⾝份认证: 匿名认证:适⽤于没有数据安全问题且不涉及访问权限的完全公开⽅式 基本认证:通过⽤分辨名(DN)和密码进⾏⾝份识别,密码识别有分为简单密码和摘要密码认证 SASL(Simple Authentication and Secure Layer)认证:在SSL和TLS安全通道基础上进⾏的⾝份认证,包括数字证书的认证 通信安全在LDAP中提供了基于SSL/TLS的通信安全保障。SSL/TLS是基于PKI信息安全技术的,是⽬前Internet上⼴泛采⽤的安全服务。TLS服务可以被LDAP通过StartTLS⽅式启动,该服务既可以提供通信中的数据保密性、完整性保护,也可以实现客户端⾝份和服务器端⾝份的双向验证。访问控制的标准:⽬前并⽆访问控制的标准,但LDAP的访问控制⾮常灵活和丰富。在LDAP中访问控制是通过访问控制策略语句来实现的,⽽RDBS和应⽤系统是通过访问控制列表来实现的。2、LDAP的应⽤领域LDAP被⼴泛⽤于基础性、关键性信息的管理。信息安全类:数字证书管理、授权管理、单点登录⽹络资源管理类:MAIL系统、DNS系统、⽹络⽤户管理、电话号码簿。科学计算类:DCE(Distributed Computing Environment,分布式计算环境),UDDI(Universal Description,Discovery andIntegration,统⼀描述,发现和集成协议)电⼦政务资源管理:内⽹组织信息服务,电⼦政务⽬录体系,⼈⼝基础库,法⼈基础库LDAP之所以能⼴泛⽤于管理⽤户信息、⽹络资源信息等,是由于LDAP具有⾼效率的查询,树状的信息管理模式,分布式的部署框架以及细致灵活的访问控制的特点。三、OpenLDAP环境搭建1.环境准备[root@ldap ~]# cat /etc/redhat-release CentOS release 6.8 (Final)[root@ldap ~]# uname -6.x86_64[root@ldap ~]# 配置rsyslog记录ldap服务⽇志:[root@ldap openldap]# cp /etc/ /etc/[root@ldap openldap]# echo "record by linuxzkq 2016/11/2" >>/etc/[root@ldap openldap]# echo "local4.* /var/log/">> /etc/ [root@ldap openldap]# tail -2 /etc/cord by linuxzkq 2016/11/2local4.* /var/log/[root@ldap openldap]# /etc/init.d/rsyslog restartShutting down system logger: [ OK ]Starting system logger: [ OK ][root@ldap openldap]# ll /var/log/ -rw-------. 1 root root 0 Nov 2 23:13 /var/log/配置LDAP数据库路径:[root@ldap openldap]# grep "directory" |grep -v "#"directory /var/lib/ldap[root@ldap openldap]# cp /usr/share/openldap-servers/DB_e /var/lib/ldap/DB_CONFIG[root@ldap openldap]# ll /var/lib/ldap total 4-rw-r--r--. 1 root root 845 Nov 2 23:17 DB_CONFIG[root@ldap openldap]# chown ldap:ldap /var/lib/ldap/DB_CONFIG[root@ldap openldap]# chmod 700 /var/lib/ldap/DB_CONFIG[root@ldap openldap]# ll /var/lib/ldap total 4-rwx------. 1 ldap ldap 845 Nov 2 23:17 DB_CONFIG[root@ldap openldap]# egrep -v "#|^$" /var/lib/ldap/DB_CONFIGset_cachesize 0 268435456 1set_lg_regionmax 262144set_lg_bsize 2097152[root@ldap openldap]# slaptest -u //测试配置⽂件是否配置成功[root@ldap openldap]# slaptest -u //测试配置⽂件是否配置成功config file testing succeeded最终LDAP完整配置⽂件:[root@ldap openldap]# egrep -v "^$|^.*#" clude /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/include /etc/openldap/schema/allow bind_v2pidfile /var/run/openldap/sfile /var/run/openldap/SCACertificatePath /etc/openldap/certsTLSCertificateFile ""OpenLDAP Server""TLSCertificateKeyFile /etc/openldap/certs/password access to * by self write by anonymous auth by * readbase bdbsuffix "dc=etiantian,dc=org"rootdn "cn=admin,dc=etiantian,dc=org"directory /var/lib/ldapindex objectClass eq,presindex ou,cn,mail,surname,givenname eq,pres,subindex uidNumber,gidNumber,loginShell eq,presindex uid,memberUid eq,pres,subindex nisMapName,nisMapEntry eq,pres,subrootpw {SSHA}mDsZ2A7nq6PCQ9CQmLTZThIDqHbxvHT3loglevel 296cachesize 1000checkpoint 2048 10[root@ldap openldap]# diff 98,108c98,101< database config< access to *< by ="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage< by * none< < # enable server status monitoring (cn=monitor)< database monitor< access to *< by ="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read< by ="cn=Manager,dc=my-domain,dc=com" read< by * none---> access to *> by self write> by anonymous auth> by anonymous auth> by * read114,117c107,116< database bdb< suffix "dc=my-domain,dc=com"< checkpoint 1024 15< rootdn "cn=Manager,dc=my-domain,dc=com"---> #database bdb> #suffix "dc=my-domain,dc=com"> #checkpoint 1024 15> #rootdn "cn=Manager,dc=my-domain,dc=com"> #add start by linuxzkq 2016/11/2> base bdb> suffix "dc=etiantian,dc=org"> rootdn "cn=admin,dc=etiantian,dc=org"> #add end by linuxzkq 2016/11/2> 141a141,145> #add start by linuxzkq 2016/11/2> loglevel 296> cachesize 1000> checkpoint 2048 10> #add end by linuxzkq 2016/11/2[root@ldap openldap]# /etc/init.d/slapd startStarting slapd: [ OK ][root@ldap openldap]# netstat -tunlp|grep slapdtcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN 3002/slapd tcp 0 0 :::389 :::* LISTEN 3002/slapd [root@ldap openldap]# lsof -i:389COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEslapd 3002 ldap 7u IPv4 22382 0t0 TCP *:ldap (LISTEN)slapd 3002 ldap 8u IPv6 22383 0t0 TCP *:ldap (LISTEN)[root@ldap openldap]# ps -ef|grep ldap|grep -v grepldap 3002 1 0 23:31 ? 00:00:00 /usr/sbin/slapd -h ldap:/// ldapi:/// -u ldap[root@ldap openldap]# chkconfig slapd on[root@ldap openldap]# chkconfig --list slapdslapd 0:off 1:off 2:on 3:on 4:o5:on 6:off查看ldap master数据库:[root@ldap openldap]# ldapldapadd ldapmodify ldapurlldapcompare ldapmodrdn ldapwhoamildapdelete ldappasswd ldapexop ldapsearch [root@ldap openldap]# ldapsearch -LLL -W -x -H ldap:// -D "cn=admin,dc=etiantian,dc=org" -b"dc=etiantian,dc=org" "(uid=*)"Enter LDAP Password: ldap_bind: Invalid credentials (49) //查询ldap数据库报错,密码对也连接不上。出错,解决ldap2.3和2.4配置冲突问题,解决⽅法如下:[root@ldap openldap]# ll /etc/openldap/slapd.d/total 8drwx------. 3 ldap ldap 4096 Nov 1 23:46 cn=config-rw-------. 1 ldap ldap 1281 Nov 1 23:46 cn=[root@ldap openldap]# rm -rf /etc/openldap/slapd.d/*[root@ldap openldap]# slaptest -f /etc/openldap/ -F /etc/openldap/slapd.d581a0d14 bdb_monitor_db_open: monitoring disabled; configure monitor database to enableconfig file testing succeeded[root@ldap openldap]# ll /etc/openldap/slapd.d total 8drwxr-x---. 3 root root 4096 Nov 2 23:59 cn=config-rw-------. 1 root root 1301 Nov 2 23:59 cn=[root@ldap openldap]# /etc/init.d/slapd restartStopping slapd: [ OK ]Checking configuration files for slapd: [FAILED]581a0daf ldif_read_file: Permission denied for "/etc/openldap/slapd.d/cn="slaptest: bad configuration file![root@ldap openldap]# chown -R /etc/openldap/slapd.d/[root@ldap openldap]# ll /etc/openldap/slapd.d total 8drwxr-x---. 3 ldap ldap 4096 Nov 2 23:59 cn=config-rw-------. 1 ldap ldap 1301 Nov 2 23:59 cn=[root@ldap openldap]# /etc/init.d/slapd restart Stopping slapd: [FAILED]Starting slapd: [ OK ][root@ldap openldap]# lsof -i:389COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEslapd 3186 ldap 7u IPv4 23490 0t0 TCP *:ldap (LISTEN)slapd 3186 ldap 8u IPv6 23491 0t0 TCP *:ldap (LISTEN)[root@ldap openldap]# ldapsearch -LLL -W -x -H ldap:// -D "cn=admin,dc=etiantian,dc=org" -b"dc=etiantian,dc=org" "(uid=*)"Enter LDAP Password: No such object (32)⾄此问题解决。查询LDAP的⽬录条⽬,介绍⼀下ldapsearch命令,具体可以使⽤man帮助⼿册查看。 -b:指定查找的节点 -D:指定查找的DN -x:使⽤简单认证 -W:查询是输⼊密码,或者使⽤-w password -h:OpenLDAP的主机地址,可以使⽤IP或者域名 -H:使⽤LDAP服务器的URI地址进⾏操作为ldap master数据库添加数据的⽅法:为ldap添加⽤户数据,有四种⽅法,分别如下,我们选择第四种⽅法进⾏试验。 1)可以直接修改slapd.d⽬录下⾯的数据⽂件,好处是不⽤重启服务,直接⽣效; 1)可以直接修改slapd.d⽬录下⾯的数据⽂件,好处是不⽤重启服务,直接⽣效; 2)安装开源⼯具migrationtools来⽣成ldif⽂件,并通过ldapadd来添加; 3)安装ldap 客户端,这种⽅法最为简单; 4)直接编辑ldif⽂件,然后通过ldapadd添加。 ⾸先我们⼿动编辑⽂件,直接复制好像会因为格式有问题。每个条⽬之间有个空格,直接复制过去会有点问题,需要你把每个条⽬之间“空⾏”的第⼀个空格删除⼀下。[root@ldap openldap]# vi : dc=etiantian,dc=orgobjectClass: organizationobjectClass: dcObjectdc: etiantiano: etiantiandn: ou=People,dc=etiantian,dc=orgobjectClass: organizationalUnitou: Peopledn: ou=group,dc=etiantian,dc=orgobjectClass: organizationalUnitou: group开始导⼊数据并初始化ldap测试数据:[root@ldap openldap]# ldapadd -x -H ldap:// -D "cn=admin,dc=etiantian,dc=org" -W -f Enter LDAP Password: adding new entry "dc=etiantian,dc=org"adding new entry "ou=People,dc=etiantian,dc=org"adding new entry "ou=group,dc=etiantian,dc=org"查询导⼊的结果:[root@ldap openldap]# ldapsearch -LLL -x -H ldap:// -D "cn=admin,dc=etiantian,dc=org" -b"dc=etiantian,dc=org" -w 123456 dn: dc=etiantian,dc=orgobjectClass: organizationobjectClass: dcObjectdc: etiantiano: etiantiandn: ou=People,dc=etiantian,dc=orgobjectClass: organizationalUnitou: Peopledn: ou=group,dc=etiantian,dc=orgobjectClass: organizationalUnitou: group查看密码验证机制列表,输⼊:[root@ldap sadoc]# saslsasl2-sample-client saslauthdsasl2-sample-server sasldblistusers2sasl2-shared-mechlist saslpasswd2[root@ldap sadoc]# saslauthd -vsaslauthd 2.1.23authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap[root@ldap sadoc]# grep -i "mech" /etc/sysconfig/saslauthd # Mechanism to use when checking passwords. Run "saslauthd -v" to get a list# of which mechanism your installation was compiled with the ablity to =pam# Options sent to the saslauthd. If the MECH is other than "pam" uncomment the next line.[root@ldap sadoc]# sed -i 's#MECH=pam#MECH=shadow#g' /etc/sysconfig/saslauthd[root@ldap sadoc]# grep -i "mech" /etc/sysconfig/saslauthd|grep -v "#" MECH=shadow[root@ldap sadoc]# /etc/init.d/saslauthd restartStopping saslauthd: [FAILED]Starting saslauthd: [ OK ][root@ldap sadoc]# ps -ef|grep saslroot 3817 1 0 21:49 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadowroot 3819 3817 0 21:49 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadowroot 3820 3817 0 21:49 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadowroot 3821 3817 0 21:49 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadowroot 3822 3817 0 21:49 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadowroot 3824 3717 0 21:49 pts/0 00:00:00 grep sasl测试saslauthd进程的认证功能:[root@ldap sadoc]# testsaslauthd -uadmin -p1234560: NO "authentication failed" //失败,因为系统⽤户⾥⾯没有这个⽤户,所以失败,下⾯添加⽤户。[root@ldap sadoc]# grep "admin" /etc/passwd[root@ldap sadoc]# id adminid: admin: No such user[root@ldap sadoc]# useradd admin[root@ldap sadoc]# passwd adminChanging password for user password: BAD PASSWORD: it is too simplistic/systematicBAD PASSWORD: is too simpleRetype new password: //设置密码为上⾯的"123456"passwd: all authentication tokens updated successfully.[root@ldap sadoc]# testsaslauthd -uadmin -p1234560: OK "Success."[root@ldap sadoc]# testsaslauthd -utest1 -p1234560: NO "authentication failed" //使⽤LDAP的⽤户测试,认证失败,说明⽬前还不⽀持LDAP的⽤户。测试通过LDAP进⾏验证:[root@ldap sadoc]# man saslauthd //man配置⽂件,输⼊"/ldap"搜索ldap相关配置。SASLAUTHD(8) BSD System Manager’s Manual SASLAUTHD(8)NAME saslauthd - sasl authentication serverSYNOPSIS saslauthd -a authmech [-Tvdchlr] [-O option] [-m mux_path] [-n threads] [-s size] [-t timeout]DESCRIPTION saslauthd is a daemon ldap (All platforms that support OpenLDAP 2.0 or higher) Authenticate against an ldap server. The ldap con- figuration parameters are read from /etc/saslau- . The location of this file can be changed with the -O parameter. See the LDAP_SASLAUTHD file included with the distribu- tion for the list of avail- able parameters.[root@ldap sadoc]# history|grep sed 8 sed -i 's/keepcache=0/keepcache=1/g' /etc/ 275 slappasswd -s 123456|sed -e "s#{SSHA}#rootpwt{SSHA}#g" >> 383 sed -i 's#cn=Manager#cn=amin#g' 384 sed -i 's#dc=my-domain#dc=etiantian#g' 385 sed -i 's#dc=com#dc=org#g' 387 sed -i 's#cn=amin#cn=admin#g' 411 sed -i 's#MECH=pam#MECH=shadow#g' /etc/sysconfig/saslauthd 426 history|grep sed[root@ldap sadoc]# sed -i 's#MECH=shadow#MECH=ldap#g' /etc/sysconfig/saslauthd[root@ldap sadoc]# grep -i "mech" /etc/sysconfig/saslauthd|grep -v "#" MECH=ldap[root@ldap sadoc]# /etc/init.d/saslauthd restartStopping saslauthd: [ OK ]Starting saslauthd: [ OK ][root@ldap sadoc]# testsaslauthd -utest1 -p1234560: NO "authentication failed"[root@ldap sadoc]# testsaslauthd -uadmin -p1234560: NO "authentication failed"再次使⽤系统⽤户admin和ldap⽤户test1认证都失败了。配置saslauthd连接LDAP的连接信息:[root@ldap sadoc]# vi /etc/ ldap_servers: ldap:///#ldap_uri: ldap:///#ldap_version: 3#ldap_start_tls: 0ldap_bind_dn: cn=admin,dc=etiantian,dc=orgldap_bind_pw: 123456ldap_search_base: ou=People,dc=etiantian,dc=orgldap_search_base: ou=People,dc=etiantian,dc=orgldap_filter: uid=%U#ldap_filter: mail=%U@p_password_attr: userPassword#ldap_sasl: 0[root@ldap sadoc]# /etc/init.d/saslauthd restartStopping saslauthd: [ OK ]Starting saslauthd: [ OK ][root@ldap sadoc]# testsaslauthd -u oldboy -p 1234560: OK "Success." //ldap⽤户认证成功[root@ldap sadoc]# testsaslauthd -u test1 -p 123456 0: OK "Success." //ldap⽤户认证成功[root@ldap sadoc]# testsaslauthd -u admin -p 1234560: NO "authentication failed" //系统⽤户admin认证失败开发脚本⼀键安装svn服务并测试成功:[root@client ~]# vi auto_install_#!/bin/sh#the scripts is auto_install_svn script command#date:2016-11-04#author:linuxzkq#mail:1729294227@#version:v1.0#yum install svnyum -y install subversion#set "keepcache=1"sed -i 's/keepcache=0/keepcache=1/g' /etc/ep "keepcache" /etc/#create svn svndata and svnpasswd directorymkdir -p /application/svndatamkdir -p /application/svnpasswd#start svnsvnserve -d -r /application/svndata/ps -ef| grep svn|grep -v grepnetstat -tunlp|grep 3690#create svn Projectsvnadmin create /application/svndata/sadoc#start config svncd /application/svndata/sadoc/conf//bin/cp -i 's/# anon-access = read/anon-access = none/g' d -i 's/# auth-access = write/auth-access = write/g' d -i 's@# password-db = passwd@password-db = /application/svnpasswd/passwd@g' d -i 's@# authz-db = authz@authz-db = /application/svnpasswd/authz@g' #start config svn passwd and authz/bin/cp authz passwd /application/svnpasswd/chmod 700 /application/svnpasswd/*cat >>/application/svnpasswd/passwd< EOFcat >>/application/svnpasswd/authz< * = EOF#restart svnpkill svnservesleep 3svnserve -d -r /application/svndata/#test local fileecho "please exec the cmd bellow:"echo "svn checkout svn://192.168.0.110/sadoc /opt --username=linuxzkq --password=123456"sleep 600配置svn通过LDAP验证并且授权:[root@ldap ~]# ll /etc/sasl2/total 4-rw-r--r--. 1 root root 49 Feb 20 2014 [root@ldap ~]# vi /etc/sasl2/check_method: saslauthdmech_list: PLAIN LOGIN[root@ldap ~]# cp /application/svndata/sadoc/conf/ /application/svndata/sadoc/conf/[root@ldap ~]# sed -i 's@# use-sasl = true@use-sasl = true@g' /application/svndata/sadoc/conf/[root@ldap ~]# grep "sasl" /application/svndata/sadoc/conf/[sasl]use-sasl = true[root@ldap ~]# vi /application/svnpasswd/authz在[groups]标签下加⼊:ldap = test1,oldboy在[sadoc:/]标签下加⼊:@ldap = rw特别注意:加⼊以上内容,给予ldap⽤户访问svn版本库的权限。[root@ldap ~]# pkill svnserve[root@ldap ~]# svnserve -d -r /application/svndata[root@ldap ~]# netstat -tunlp|grep 3690tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 1870/svnserve[root@ldap ~]# svn checkout svn://192.168.0.111/sadoc /opt --username=oldboy --password=123456A /opt/aA /opt/ /opt/bA /opt/cA /opt/dA /opt/ /opt/ /opt/新建 Microsoft Access 数据库.accdbA /opt/cked out revision d out revision 48.[root@ldap ~]# svn ls svn://192.168.0.111/sadoc --username=test1 --password=123456 d通过以上结果,可以看出ldap⽤户oldboy访问svn版本库正常。svn通过ldap验证的总结:1.配置成功saslauthd,前提条件;2.配置/etc/sasl2/;[root@ldap ~]# vi /etc/sasl2/check_method: saslauthdmech_list: PLAIN LOGIN3.配置好svn服务,并且开启sasl⽀持,重启svn;[root@ldap ~]# grep "sasl" /application/svndata/sadoc/conf/[sasl]use-sasl = true4.配置authz授权ldap⽤户访问相关项⽬的权限;[root@ldap ~]# vi /application/svnpasswd/authz在[groups]标签下加⼊:ldap = test1,oldboy在[sadoc:/]标签下加⼊:@ldap = rw5.测试访问linux或win32[root@ldap ~]# svn ls svn://192.168.0.111/sadoc --username=test1 --password=123456
发布评论