CentOS Linux release 7.8.2003 (Core)
openldap-clients-2.4.44-21.e17_6.x86_64
openldap-servers-2.4.44-21.e17_6.x86_64
openldap-2.4.44-21.e17_6.x86_64
一、环境准备
关闭 selinux firewalld
setenforce 0
systemctl stop firewalld.service
systemctl disable firewalld.service
二、OPENLDAP服务搭建
1、安装openldap
yum install -y openldap openldap-clients openldap-servers
2、启动openldap
systemctl start slapd
systemctl enable slapd
3、配置ldap超级管理员
生成密码,等一下作为 olcRootPW 的值
slappasswd -s "123456"
{SSHA}yGu5OYMOpwVa2I/6Z8uwac/bo2KHjaW+
创建admin.ldif 文件
# 先查看对应的配置, 有的版本不是{2}hdb, 要相对修改
ls /etc/openldap/slapd.d/cn=config/
# admin.ldif
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=example,dc=com
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=admin,dc=example,dc=com
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: {SSHA}yGu5OYMOpwVa2I/6Z8uwac/bo2KHjaW+
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read by dn.base="cn=admin,dc=example,dc=com" read by * none
导入配置
ldapmodify -Y EXTERNAL -H ldapi:/// -f admin.ldif
4、配置数据库
openldap默认使用的数据库是BerkeleyDB
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ld