您好,登錄后才能下訂單哦!
今天小編給大家分享的是openldap安裝與配置的詳細(xì)介紹,相信大部分人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,話不多說,一起往下看吧。
目前的架構(gòu)分為如下兩種:
互聯(lián)網(wǎng)命名組織架構(gòu)
流程:
objectClass分為如下幾類
~]# yum -y install wget curl git
~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
~]# yum -y install epel-release
~]# yum -y install openldap openldap-servers openldap-clients compat-openladp openldap-devel migrationtools
~]# cd /etc/openldap/
~]# mv slapd.d/ slapd.d.bak
~]# mkdir slapd.d && slappasswd #生成密鑰
New password:
Re-enter new password:
{SSHA}CYZ2put971vDLOeZVvbG7W9E3aOjantN
~]# cp /usr/share/openldap-servers/slapd.ldif /etc/openldap/
#### 配置schema加載
~]# vim /etc/openldap/slapd.ldif
cn: schema
include: file:///etc/openldap/schema/core.ldif
include: file:///etc/openldap/schema/collective.ldif
include: file:///etc/openldap/schema/corba.ldif
include: file:///etc/openldap/schema/cosine.ldif
include: file:///etc/openldap/schema/duaconf.ldif
include: file:///etc/openldap/schema/dyngroup.ldif
include: file:///etc/openldap/schema/inetorgperson.ldif
include: file:///etc/openldap/schema/java.ldif
include: file:///etc/openldap/schema/misc.ldif
include: file:///etc/openldap/schema/nis.ldif
include: file:///etc/openldap/schema/openldap.ldif
include: file:///etc/openldap/schema/pmi.ldif
include: file:///etc/openldap/schema/ppolicy.ldif
olcAccess: to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,c
n=auth" read by dn.base="cn=admin,dc=neuvision,dc=ai" read by * none
olcSuffix: dc=neuvision,dc=ai
olcRootDN: cn=admin,dc=neuvision,dc=ai
olcRootPW: {SSHA}WslU/LDXGf/WTLLYGafxBzmT6y1CDabz
~ ]# slapadd -n 0 -F /etc/openldap/slapd.d -l slapd.ldif #生成配置
~]# chown -R ldap.ldap /etc/openldap/slapd.d
~]# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG #拷貝數(shù)據(jù)庫配置文件
~]# chown ldap.ldap -R /var/lib/ldap/
~]# systemctl start slapd && systemctl enable slapd #服務(wù)啟動
~]# vim /usr/share/migrationtools/migrate_common.ph #導(dǎo)入數(shù)據(jù)腳本配置
# Default DNS domain
$DEFAULT_MAIL_DOMAIN = "51cto.com";
# Default base
$DEFAULT_BASE = "dc=51cto,dc=com";
# such as person.
$EXTENDED_SCHEMA = 1;
~ ]# /usr/share/migrationtools/migrate_base.pl > /etc/openldap/basedomain.ldif #生成domain(域)文件
~ ]# ldapadd -x -D cn=admin,dc=51cto,dc=com -W -f /etc/openldap/basedomain.ldif #添加條目
~]# mkdir /root/ldif && cd /root/ldif
~]# vim config_init.ldif
dn: dc=51cto,dc=com
objectClass: dcObject
objectClass: organization
o: wanghui
dc: neuvision
~]# ldapadd -x -D "cn=admin,dc=51cto,dc=com" -W -f config_init.ldif
~]# ldapsearch -x -b 'dc=51cto,dc=com' '(objectClass=*)' #查詢記錄
~]# ldapsearch -H ldapi:/// -Y EXTERNAL -b "cn=config" -LLL -Q #ladpi查詢
系統(tǒng)文件: /etc/openldap/ldap.conf
用戶文件:$HOME/ldaprc $HOME/.ldaprc
ldapsearch -x -W -D 'cn=admin,dc=51cto,dc=com' -H ldaps://10.18.99.41 #連接ldap
主配置文件布局如下:
dn: cn=config
dn: cn=module,cn=config
dn: cn=schema,cn=config
dn: olcDatabase=config,cn=config
~ ]# /usr/share/migrationtools/migrate_base.pl > /etc/openldap/basedomain.ldif #生成domain(域)文件
# 需要創(chuàng)建好一些用戶和組,并且將用戶添加到組,groupadd DEV,useradd wanghui -g DEV
~]# tail -3 /etc/group > system_group
DEV:x:1003:
OPS:x:1004:
QA:x:1005:
~]# tail -4 /etc/passwd > system_user
zhangsan:x:1000:1004::/home/zhansan:/bin/bash
lisi:x:1001:1003::/home/lisi:/bin/bash
wangwu:x:1002:1003::/home/wangwu:/bin/bash
mazi:x:1003:1005::/home/mazi:/bin/bash
~]#ldapadd -x -W -D "cn=admin,dc=51cto,dc=com" -f base.ldif
~]# ldapadd -x -W -D "cn=admin,dc=51cto,dc=com" -f group.ldif # 添加組到ldap
~]# ldapadd -x -W -D "cn=admin,dc=51cto,dc=com" -f user.ldif
~]# mkdir /data/logs/slapd
~]# touch /data/logs/slapd/slapd.log
~]# chown ldap:ldap /data/logs/slapd/ -R
----- 創(chuàng)建日志ldif
~]# vim log.ldif
dn: cn=config
changetype: modify
add: olcLogLevel
olcLogLevel: stats
~]# ldapadd -Y EXTERNAL -H ldapi:/// -f log.ldif #加載配置
~]# cat /etc/openldap/slapd.d/cn\=config.ldif #檢查是否加載成功
olcLogLevel: stats
~]# vim /etc/rsyslog.conf #配置日志
local7.* /var/log/boot.log
local4.* /data/logs/slapd/slapd.log
~ ]# systemctl restart rsyslog
~]# systemctl restart slapd
~]# vim /etc/logrotate.d/slapd
/data/logs/slapd/slapd.log {
daily
rotate 5
copytruncate
dateext
missingok
}
~]# systemctl restart rsyslog
~]# logrotate -f /etc/logrotate.d/slapd #測試日志切割
~]# ldapsearch -x -LLL uid=wanghui #查詢用戶。然后看日志是否正常
~]# yum -y install phpldapadmin
~]# vim /etc/httpd/conf.d/phpldapadmin.conf
<VirtualHost *:80>
ServerName ldap.51cto.com
Alias /phpldapadmin /usr/share/phpldapadmin/htdocs
Alias /ldapadmin /usr/share/phpldapadmin/htdocs
<Directory /usr/share/phpldapadmin/htdocs>
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
Require local
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
</VirtualHost>
~]# vim /etc/phpldapadmin/config.php
$servers->setValue('login','attr','dn');
~ ]# systemctl start httpd && systemctl enable httpd
~]# cat config_init.ldif
dn: dc=51cto,dc=com
objectClass: dcObject
objectClass: organization
o: wanghui
dc: neuvision
~]# ldapadd -x -D 'cn=admin,dc=neuvision,dc=ai' -W -f config_init.ldif
Generic: Organisational Unit
密碼類型是ssha
選擇對應(yīng)的GID
選擇對應(yīng)的loginshell
----------
返回終端查詢下創(chuàng)建的用戶
~]# ldapsearch -x -LL -b '51cto,dc=com' '(uid=whui)'
~]# ldapsearch -x -LL uid=whui
~#] vim /etc/phpldapadmin/config.php
$config->custom->appearance['hide_template_warning'] = true;
~#]systemctl restart httpd
以上就是openldap安裝與配置的詳細(xì)內(nèi)容了,看完之后是否有所收獲呢?如果想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。