千家信息网

CentOS7如何部署OpenLDAP服务

发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,本篇内容介绍了"CentOS7如何部署OpenLDAP服务"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所
千家信息网最后更新 2026年11月02日CentOS7如何部署OpenLDAP服务

本篇内容介绍了"CentOS7如何部署OpenLDAP服务"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

OpenLDAP 是一款轻量级目录访问协议(Lightweight Directory Access Protocol,LDAP),属于开源集中账号管理架构的实现,且支持众多系统版本,被广大互联网公司所采用。

安装ldap服务

[root@ldap ~]# yum install -y openldap-servers openldap-clients[root@ldap ~]# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG[root@ldap ~]# chown ldap. /var/lib/ldap/DB_CONFIG[root@ldap ~]# systemctl start slapd[root@ldap ~]# systemctl enable slapd

配置ldap服务

# 生成管理员密码

[root@ldap ~]# slappasswdNew password:Re-enter new password:{SSHA}xxxxxxxxxxxxxxxxxxxxxxxx[root@ldap ~]# vim chrootpw.ldif# specify the password generated above for "olcRootPW" sectiondn: olcDatabase={0}config,cn=configchangetype: modifyadd: olcRootPWolcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx[root@ldap ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f chrootpw.ldifSASL/EXTERNAL authentication startedSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=authSASL SSF: 0modifying entry "olcDatabase={0}config,cn=config"

导入基本模式

[root@ldap ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldifSASL/EXTERNAL authentication startedSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=authSASL SSF: 0adding new entry "cn=cosine,cn=schema,cn=config"[root@ldap ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldifSASL/EXTERNAL authentication startedSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=authSASL SSF: 0adding new entry "cn=nis,cn=schema,cn=config"[root@ldap ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldifSASL/EXTERNAL authentication startedSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=authSASL SSF: 0adding new entry "cn=inetorgperson,cn=schema,cn=config"

在ldap的DB中设置域名

# 生成目录管理员密码

[root@ldap ~]# slappasswdNew password:Re-enter new password:{SSHA}xxxxxxxxxxxxxxxxxxxxxxxx[root@ldap ~]# vim chdomain.ldif# replace to your own domain name for "dc=***,dc=***" section# specify the password generated above for "olcRootPW" sectiondn: olcDatabase={1}monitor,cn=configchangetype: modifyreplace: olcAccessolcAccess: {0}to * bydn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"read by dn.base="cn=Manager,dc=jumpserver,dc=tk" read by * nonedn: olcDatabase={2}hdb,cn=configchangetype: modifyreplace: olcSuffixolcSuffix: dc=jumpserver,dc=tkdn: olcDatabase={2}hdb,cn=configchangetype: modifyreplace: olcRootDNolcRootDN: cn=Manager,dc=jumpserver,dc=tkdn: olcDatabase={2}hdb,cn=configchangetype: modifyadd: olcRootPWolcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxxdn: olcDatabase={2}hdb,cn=configchangetype: modifyadd: olcAccessolcAccess: {0}to attrs=userPassword,shadowLastChange bydn="cn=Manager,dc=jumpserver,dc=tk" write by anonymous auth by self write by *noneolcAccess: {1}to dn.base="" by * readolcAccess: {2}to * by dn="cn=Manager,dc=jumpserver,dc=tk" write by * read[root@ldap ~]# ldapmodify -Y EXTERNAL -H ldapi:/// -f chdomain.ldifSASL/EXTERNAL authentication startedSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=authSASL SSF: 0modifying entry "olcDatabase={1}monitor,cn=config"modifying entry "olcDatabase={2}hdb,cn=config"modifying entry "olcDatabase={2}hdb,cn=config"modifying entry "olcDatabase={2}hdb,cn=config"[root@ldap ~]# vim basedomain.ldif# replace to your own domain name for "dc=***,dc=***" sectiondn: dc=jumpserver,dc=tkobjectClass: topobjectClass: dcObjectobjectclass: organizationo: Server tkdc: jumpserverdn: cn=Manager,dc=jumpserver,dc=tkobjectClass: organizationalRolecn: Managerdescription: Directory Managerdn: ou=People,dc=jumpserver,dc=tkobjectClass: organizationalUnitou: Peopledn: ou=Group,dc=jumpserver,dc=tkobjectClass: organizationalUnitou: Group[root@ldap ~]# ldapadd -x -D cn=Manager,dc=jumpserver,dc=tk -W -f basedomain.ldifEnter LDAP Password: # 输入目录管理员密码adding new entry "dc=jumpserver,dc=tk"adding new entry "cn=Manager,dc=jumpserver,dc=tk"adding new entry "ou=People,dc=jumpserver,dc=tk"adding new entry "ou=Group,dc=jumpserver,dc=tk"

开放端口

# firewall-cmd --add-service=ldap --permanentsuccess# firewall-cmd --reloadsuccess

添加一个用户

# 生成用户密码

[root@ldap ~]# slappasswdNew password:Re-enter new password:{SSHA}xxxxxxxxxxxxxxxxx[root@ldap ~]# vi ldapuser.ldif# create new# replace to your own domain name for "dc=***,dc=***" sectiondn: uid=test,ou=People,dc=jumpserver,dc=tkobjectClass: inetOrgPersonobjectClass: posixAccountobjectClass: shadowAccountcn: testsn: LinuxuserPassword: {SSHA}xxxxxxxxxxxxxxxxxloginShell: /bin/bashuidNumber: 1000gidNumber: 1000homeDirectory: /home/testdn: cn=test,ou=Group,dc=jumpserver,dc=tkobjectClass: posixGroupcn: testgidNumber: 1000memberUid: test[root@ldap ~]# ldapadd -x -D cn=Manager,dc=jumpserver,dc=tk -W -f ldapuser.ldifEnter LDAP Password:adding new entry "uid=test,ou=People,dc=jumpserver,dc=tk"adding new entry "cn=test,ou=Group,dc=jumpserver,dc=tk"[root@ldap ~]# ldapsearch -x -D "cn=Manager,dc=jumpserver,dc=tk" -W -b ""dc=jumpserver,dc=tk"

"CentOS7如何部署OpenLDAP服务"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!

服务 密码 管理 目录 管理员 生成 内容 更多 用户 知识 实用 学有所成 接下来 互联网 公司 困境 域名 实际 情况 文章 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 互联网最新的科技 朗新科技与工业互联网 互联网科技开发公司 互联网科技大会 互联网科技有限公司 翻译 济南华为互联网科技产业总部基地 中国互联网有什么科技含量 重庆互联网医院沙龙医盟信息科技 世界互联网科技公司市值排名 广州市恰铎互联网科技有限公司 互联网科技如何创业 北京市互联网新科技 抖集互联网科技技术咨询 福州德业互联网科技 中国新注册互联网科技 湖北辰鑫科技互联网 互联网金融运营模式中的金融科技 青岛易易互联网科技 承德科技产业互联网平台 上海旺乐尼互联网科技有限公司 百单网互联网科技有限公司 广东万易互联网科技有限公司惠州分公司 互联网佳科技有限公司 科技企业和互联网企业 互联网 科技公司 中国互联网科技发展 善班互联网科技有限公司 上游互联网科技 天速互联网络科技有限公司 恒生互联网科技趋势
0