1,ldap搭建

1,关闭selinux
2,如果修改了hostname,相应的要修改hosts,不然执行命令会卡住,很长时间才会执行完成
3,安装软件
yum install -y openldap openldap-clients openldap-servers vim
4,配置openldap server
4-1
vim /etc/openldap/slapd.d/cn=config/olcDatabase={1}monitor.ldif
将
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=extern
 al,cn=auth" read by dn.base="cn=Manager,dc=my-domain,dc=com" read by * none
改为:
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=extern
 al,cn=auth" read by dn.base="cn=admin-test,dc=test,dc=com" read by * none

4-2
vim /etc/openldap/slapd.d/cn=config/olcDatabase={2}hdb.ldif
将
olcSuffix: dc=my-domain,dc=com
olcRootDN: cn=Manager,dc=my-domain,dc=com
改为:
olcSuffix: dc= test,dc=com
olcRootDN: cn= admin-test,dc=test,dc=com

然后添加一行
olcRootPW: 123456 
此处设置的是认证密码

4-3
拷贝DB文件
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
修改该文件的权限
chown -R ldap:ldap /var/lib/ldap/
4-4
测试配置文件是否正确
slaptest -u
4-5启动服务
systemctl start slapd
systemctl enable slapd


4-6添加scheme表
ldapadd -Y EXTERNAL -H ldapi:/// -D "cn=config" -f /etc/openldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -D "cn=config" -f /etc/openldap/schema/cosine.ldif

  

posted @ 2022-10-04 15:38  pwcc  阅读(109)  评论(0)    收藏  举报