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)行連接查看,添加用戶。

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

二、使用LDAP Admin工具創(chuàng)建用戶。
1、下載并運(yùn)行LDAP Admin工具建立連接。

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

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


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

填入用戶信息:

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

三、使用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。

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

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

4、添加用戶:


創(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



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


配置文件名:****
配置文件密碼:********
配置openldap服務(wù)端,設(shè)置賬戶類型,并點(diǎn)擊'save'。


添加Samba3模塊:

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



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

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

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


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


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

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