Centos7.6搭建非加密Openldap服务端

2019-05-10  本文已影响0人  Firetheworld

openldap的部署方式有yum安装方式,。因为docker方式部署后,客户端linux打开ldap认证后,客户端没有出现用户,暂时不使用docker方式进行部署。
目录:
一、yum方式进行openldap的服务端进行安装。
二、使用LDAP Admin工具创建用户。
三、使用phpldapadmin创建用户。
四、使用LAM(LDAP Account Manager)创建用户。


sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config && systemctl disable firewalld && reboot

2、安装ntp时间服务器,进行时间校对(可选)

yum -y install ntp

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

1、相关的yum包以及用途。
2、重新生成配置文件

安装包功能以及介绍:
openldap: OpenLDAP服务端和客户端用的库文件
openldap-servers: 服务端程序
openldap-clients: 客户端程序
compat-openldap: OpenLDAP 兼容性库
openldap-devel: 开发包,(可选)
openldap-servers-sql: 支持sql模块,(可选)
migrationtools: 实现OpenLDAP用户及用户组的添加,导入系统账户(可选)

 yum -y install openldap openldap-servers openldap-clients compat-openldap 

cd /etc/openldap

mv slapd.d slapd.d.bak

mkdir slapd.d

slappasswd -s 123456

{SSHA}BiQBgi1QCsYtl3F8sK/jY5tGL43/PCHq

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: 更改为自己设置的域。

cd /etc/openldap/

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

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

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

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"

添加一个BaseDN后,还需要添加用户,才能进行远程访问。
可以使用LdapAdmin进行连接查看,添加用户。


LDAP Admin连接设置

Host:openldap的服务地址
Base:
Account: 也可以选择Anonymous connection(匿名访问,只能查看不能添加用户)


LDAP Admin登陆成功的界面

二、使用LDAP Admin工具创建用户。

1、下载并运行LDAP Admin工具建立连接。


LDAP Admin

点击start-New connection-填写host、base、Account进行连接。
2、创建两个OU分别为group、People。

创建两个OU

在group下创建posixGroup组。


image.png

在People下创建用户。


image.png

填入用户信息:


image.png
点击G1组的Properties,将post用户添加至G1组中。
image.png

三、使用phpldapadmin创建用户。

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服务端地址。
PHPLDAPADMIN_HTTPS:不使用SSL加密协议

2、输入 http://ldapip 登陆openldap。

phpadminldap界面
也可以使用匿名进行访问,但是无法进行用户创建。
2、创建两个OU,分别命名为:group、People
image.png
3、在group下创建一个POSIX Group
image.png
4、添加用户:
image.png image.png

创建用户成功。

四、使用LAM(LDAP Account Manager)创建用户。

1、docker安装LAM

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

映射的8080端口可以设置为其他端口进行访问。

2、访问LAM,配置lam。
ip:8080,默认密码为:lam


访问LAM
image.png
点击Edit server profiles

点击Edit server profiles,再次点击Manager server profiles1,配置如下信息后,点击Add,输入默认lam密码'lam'

添加profiles
输入lam密码

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

配置openldap服务端,设置账户类型,并点击'save'。


添加openldap服务地址 填写基本DN

添加Samba3模块:


image.png

添加Samba3账号类型,并下拉填写基本DN,再去Modules,添加Samba domains。


添加Samba3账号类型 添加Samba domains
image.png

登陆openldap服务端,选择刚才创建的server profile文件,输入ldap密码,登陆。


登陆openldap服务端
新建立的用户的时候,会提示是否创建People,group的OU,点击'create'
Create

添加组以及用户,填写组名称,点击'save'。


添加G1组
查看G1
添加用户:post,并设置密码:
添加post
设置post的密码
再次点击'Unix',能看到post用户。并点击‘Save’
点击Unix

点击`User``,能查看到用户信息。post用户创建完毕。


查看创建的用户
上一篇下一篇

猜你喜欢

热点阅读