写完这个文章有一阵了,合计下个月可以轮到这个文章记录发上来了,后来被群里(56479030)的童鞋们要看,只能提前发了。
系统信息
1 2 3 4 5 |
[root@kinggoo ~]# cat /etc/redhat-release CentOS release 6.4 (Final) [root@kinggoo ~]# uname -a Linux kinggoo.com 2.6.32-358.23.2.el6.i686 #1 SMP Wed Oct 16 17:21:31 UTC 2013 i686 i686 i386 GNU/Linux |
安装openldap(2.4.23-32)
1 |
yum -y install openldap openldap-* |
确认/etc/sysconfig/ldap的内容如下面默认一般不需要修改
1 2 3 4 5 |
[root@kinggoo openldap]# cat /etc/sysconfig/ldap |grep -v -E "^$|^#" SLAPD_LDAP=yes SLAPD_LDAPI=yes #未开启ssl SLAPD_LDAPS=no |
配置文件的操作
1 2 3 4 5 6 |
[root@kinggoo openldap]# cp -rf /etc/openldap/slapd.d /etc/openldap/slapd.d_`date +%Y%m%d`.bak [root@kinggoo openldap]# rm -rf /etc/openldap/slapd.d/* [root@kinggoo openldap]# touch /etc/openldap/slapd.conf [root@kinggoo openldap]# echo -e "pidfile /var/run/openldap/slapd.pid\nargsfile /var/run/openldap/slapd.args" > /etc/openldap/slapd.conf [root@kinggoo openldap]# slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d 返回信息:config file testing succeeded |
修改文件
1 2 3 4 |
[root@kinggoo openldap]# cd /etc/openldap/slapd.d/cn=config/ [root@kinggoo cn=config]# vim olcDatabase\=\{0\}config.ldif #注意需要修改第四行内的olcAccess: {0}to * by * none改为如下信息(在星号后面的by前面应该是两个英文半角的空格) olcAccess: {0}to * by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth manage by * break |
新建一个ldif文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@kinggoo cn=config]# touch /etc/openldap/slapd.d/cn=config/olcDatabase\=\{1\}monitor.ldif #向其内添加如下信息,注意后面和前面不要有空格 [root@kinggoo cn=config]# cat olcDatabase\=\{1\}monitor.ldif dn: olcDatabase={1}monitor objectClass: olcDatabaseConfig olcDatabase: {1}monitor olcAccess: {1}to * by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth manage by * break olcAddContentAcl: FALSE olcLastMod: TRUE olcMaxDerefDepth: 15 olcReadOnly: FALSE olcMonitoring: FALSE structuralObjectClass: olcDatabaseConfig creatorsName: cn=config modifiersName: cn=config |
修改slapd.d目录的属主和权限,并启动ldap:
1 2 3 4 5 6 7 |
[root@kinggoo cn=config]# chown -R ldap.ldap /etc/openldap/slapd.d [root@kinggoo cn=config]# chown -R ldap.ldap /var/lib/ldap [root@kinggoo cn=config]# chmod -R 700 /etc/openldap/slapd.d [root@kinggoo cn=config]# chkconfig --add slapd [root@kinggoo cn=config]# chkconfig --level 345 slapd on [root@kinggoo cn=config]# service slapd start 不报错就没什么问题,有问题的话估计就是你哪个地方执行错误了,重头看看 |
执行如下几条命令
依次会返回
ldapadd -Y EXTERNAL -[……]
最新评语