新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
CentOS7部署OpenLDAP服務(wù)
OpenLDAP 是一款輕量級目錄訪問協(xié)議(Lightweight Directory Access Protocol,LDAP),屬于開源集中賬號管理架構(gòu)的實現(xiàn),且支持眾多系統(tǒng)版本,被廣大互聯(lián)網(wǎng)公司所采用。

創(chuàng)新互聯(lián)建站-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比安新網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式安新網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋安新地區(qū)。費用合理售后完善,十多年實體公司更值得信賴。
安裝ldap服務(wù)
[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服務(wù)
# 生成管理員密碼
[root@ldap ~]# slappasswd
New password:
Re-enter new password:
{SSHA}xxxxxxxxxxxxxxxxxxxxxxxx
[root@ldap ~]# vim chrootpw.ldif
# specify the password generated above for "olcRootPW" section
dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx
[root@ldap ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f chrootpw.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={0}config,cn=config"
導(dǎo)入基本模式
[root@ldap ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=cosine,cn=schema,cn=config"
[root@ldap ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=nis,cn=schema,cn=config"
[root@ldap ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=inetorgperson,cn=schema,cn=config"
在ldap的DB中設(shè)置域名
# 生成目錄管理員密碼
[root@ldap ~]# slappasswd
New 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" section
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=Manager,dc=jumpserver,dc=tk" read by * none
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=jumpserver,dc=tk
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=Manager,dc=jumpserver,dc=tk
dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxx
dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange by
dn="cn=Manager,dc=jumpserver,dc=tk" write by anonymous auth by self write by *
none
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=Manager,dc=jumpserver,dc=tk" write by * read
[root@ldap ~]# ldapmodify -Y EXTERNAL -H ldapi:/// -f chdomain.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying 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=***" section
dn: dc=jumpserver,dc=tk
objectClass: top
objectClass: dcObject
objectclass: organization
o: Server tk
dc: jumpserver
dn: cn=Manager,dc=jumpserver,dc=tk
objectClass: organizationalRole
cn: Manager
description: Directory Manager
dn: ou=People,dc=jumpserver,dc=tk
objectClass: organizationalUnit
ou: People
dn: ou=Group,dc=jumpserver,dc=tk
objectClass: organizationalUnit
ou: Group
[root@ldap ~]# ldapadd -x -D cn=Manager,dc=jumpserver,dc=tk -W -f basedomain.ldif
Enter 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 --permanent
success
# firewall-cmd --reload
success
添加一個用戶
# 生成用戶密碼
[root@ldap ~]# slappasswd
New password:
Re-enter new password:
{SSHA}xxxxxxxxxxxxxxxxx
[root@ldap ~]# vi ldapuser.ldif
# create new
# replace to your own domain name for "dc=***,dc=***" section
dn: uid=test,ou=People,dc=jumpserver,dc=tk
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
cn: test
sn: Linux
userPassword: {SSHA}xxxxxxxxxxxxxxxxx
loginShell: /bin/bash
uidNumber: 1000
gidNumber: 1000
homeDirectory: /home/test
dn: cn=test,ou=Group,dc=jumpserver,dc=tk
objectClass: posixGroup
cn: test
gidNumber: 1000
memberUid: test
[root@ldap ~]# ldapadd -x -D cn=Manager,dc=jumpserver,dc=tk -W -f ldapuser.ldif
Enter 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服務(wù)
文章起源:http://m.fisionsoft.com.cn/article/cdedsjg.html


咨詢
建站咨詢
