Centos7.6搭建非加密Openldap服務(wù)端

openldap的部署方式有yum安裝方式,。因?yàn)閐ocker方式部署后,客戶端linux打開ldap認(rèn)證后,客戶端沒有出現(xiàn)用戶,暫時(shí)不使用docker方式進(jìn)行部署。
目錄:
一、yum方式進(jìn)行openldap的服務(wù)端進(jìn)行安裝。
二、使用LDAP Admin工具創(chuàng)建用戶。
三、使用phpldapadmin創(chuàng)建用戶。
四、使用LAM(LDAP Account Manager)創(chuàng)建用戶。


  • 操作系統(tǒng):Centos7.6
  • 安裝前環(huán)境操作:
    1、關(guān)閉防火墻以及selinux,并重啟生效。
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config && systemctl disable firewalld && reboot

2、安裝ntp時(shí)間服務(wù)器,進(jìn)行時(shí)間校對(duì)(可選)

yum -y install ntp

一、openldap的yum安裝方式如下:

1、相關(guān)的yum包以及用途。
2、重新生成配置文件

安裝包功能以及介紹:
openldap: OpenLDAP服務(wù)端和客戶端用的庫文件
openldap-servers: 服務(wù)端程序
openldap-clients: 客戶端程序
compat-openldap: OpenLDAP 兼容性庫
openldap-devel: 開發(fā)包,(可選)
openldap-servers-sql: 支持sql模塊,(可選)
migrationtools: 實(shí)現(xiàn)OpenLDAP用戶及用戶組的添加,導(dǎo)入系統(tǒng)賬戶(可選)

 yum -y install openldap openldap-servers openldap-clients compat-openldap 
  • 備份原配置文件

cd /etc/openldap

mv slapd.d slapd.d.bak

mkdir slapd.d

  • 配置管理員密碼(下面slapd.ldif配置文件會(huì)使用到):

slappasswd -s 123456

{SSHA}BiQBgi1QCsYtl3F8sK/jY5tGL43/PCHq

  • 復(fù)制配置文件過來,進(jìn)行重新編輯:

cp /usr/share/openldap-servers/slapd.ldif /etc/openldap/

vim /etc/openldap/slapd.ldif

……
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
……
olcSuffix: dc=zteict,dc=org
olcRootDN: cn=admin,dc=zteict,dc=org
olcRootPW: {SSHA}BiQBgi1QCsYtl3F8sK/jY5tGL43/PCHq

include表示添加模塊,
dc: 更改為自己設(shè)置的域。

  • 生成配置文件

cd /etc/openldap/

slapadd -n 0 -F slapd.d -l slapd.ldif

_#################### 100.00% eta none elapsed none fast!
Closing DB...

  • 給目錄添加ldap管理權(quán)限,并啟動(dòng)slapd服務(wù)。

chown -R ldap:ldap slapd.d

cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

chown -R ldap:ldap /var/lib/ldap

systemctl start slapd && systemctl status slapd

systemctl enable slapd

  • 導(dǎo)入一個(gè)基本DN

mkdir /root/ldif

cd /root/ldif

vim config_init.ldif

dn: dc=zteict,dc=org
objectclass: dcObject
objectclass: organization
o: zteict
dc: zteict

ldapadd -x -D "cn=admin,dc=zteict,dc=org" -W -f config_init.ldif

config_init.ldif
Enter LDAP Password:
adding new entry "dc=zteict,dc=org"

添加一個(gè)BaseDN后,還需要添加用戶,才能進(jìn)行遠(yuǎn)程訪問。
可以使用LdapAdmin進(jìn)行連接查看,添加用戶。


LDAP Admin連接設(shè)置

Host:openldap的服務(wù)地址
Base:
Account: 也可以選擇Anonymous connection(匿名訪問,只能查看不能添加用戶)


LDAP Admin登陸成功的界面

二、使用LDAP Admin工具創(chuàng)建用戶。

1、下載并運(yùn)行LDAP Admin工具建立連接。


LDAP Admin

點(diǎn)擊start-New connection-填寫host、base、Account進(jìn)行連接。
2、創(chuàng)建兩個(gè)OU分別為group、People。

創(chuàng)建兩個(gè)OU

在group下創(chuàng)建posixGroup組。


image.png

在People下創(chuàng)建用戶。


image.png

填入用戶信息:


image.png

點(diǎn)擊G1組的Properties,將post用戶添加至G1組中。
image.png

三、使用phpldapadmin創(chuàng)建用戶。

1、使用docker安裝phpldapadmin工具。

 docker run   -e PHPLDAPADMIN_LDAP_HOSTS="10.18.224.189"   -e PHPLDAPADMIN_HTTPS=false   -p 80:80   -h phpldapadmin-service   --name phpldapadmin-service   -d osixia/phpldapadmin:latest

PHPLDAPADMIN_LDAP_HOSTS:openldap服務(wù)端地址。
PHPLDAPADMIN_HTTPS:不使用SSL加密協(xié)議

2、輸入 http://ldapip 登陸openldap。

phpadminldap界面

也可以使用匿名進(jìn)行訪問,但是無法進(jìn)行用戶創(chuàng)建。
2、創(chuàng)建兩個(gè)OU,分別命名為:group、People
image.png

3、在group下創(chuàng)建一個(gè)POSIX Group
image.png

4、添加用戶:
image.png

image.png

創(chuàng)建用戶成功。

四、使用LAM(LDAP Account Manager)創(chuàng)建用戶。

1、docker安裝LAM

docker run -p 8080:80  --name lam -d ldapaccountmanager/lam:stable

映射的8080端口可以設(shè)置為其他端口進(jìn)行訪問。

2、訪問LAM,配置lam。
ip:8080,默認(rèn)密碼為:lam


訪問LAM

image.png

點(diǎn)擊Edit server profiles

點(diǎn)擊Edit server profiles,再次點(diǎn)擊Manager server profiles1,配置如下信息后,點(diǎn)擊Add,輸入默認(rèn)lam密碼'lam'

添加profiles

輸入lam密碼

配置文件名:****
配置文件密碼:********

配置openldap服務(wù)端,設(shè)置賬戶類型,并點(diǎn)擊'save'。


添加openldap服務(wù)地址
填寫基本DN

添加Samba3模塊:


image.png

添加Samba3賬號(hào)類型,并下拉填寫基本DN,再去Modules,添加Samba domains。


添加Samba3賬號(hào)類型
添加Samba domains

image.png

登陸openldap服務(wù)端,選擇剛才創(chuàng)建的server profile文件,輸入ldap密碼,登陸。


登陸openldap服務(wù)端

新建立的用戶的時(shí)候,會(huì)提示是否創(chuàng)建People,group的OU,點(diǎn)擊'create'
Create

添加組以及用戶,填寫組名稱,點(diǎn)擊'save'。


添加G1組

查看G1

添加用戶:post,并設(shè)置密碼:
添加post

設(shè)置post的密碼

再次點(diǎn)擊'Unix',能看到post用戶。并點(diǎn)擊‘Save’
點(diǎn)擊Unix

點(diǎn)擊`User``,能查看到用戶信息。post用戶創(chuàng)建完畢。


查看創(chuàng)建的用戶
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容