openldap的部署方式有yum安装方式,。因为docker方式部署后,客户端linux打开ldap认证后,客户端没有出现用户,暂时不使用docker方式进行部署。
目录:
一、yum方式进行openldap的服务端进行安装。
二、使用LDAP Admin工具创建用户。
三、使用phpldapadmin创建用户。
四、使用LAM(LDAP Account Manager)创建用户。
- 操作系统:Centos7.6
- 安装前环境操作:
1、关闭防火墙以及selinux,并重启生效。
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
- 配置管理员密码(下面slapd.ldif配置文件会使用到):
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...
- 给目录添加ldap管理权限,并启动slapd服务。
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
- 导入一个基本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"
添加一个BaseDN后,还需要添加用户,才能进行远程访问。
可以使用LdapAdmin进行连接查看,添加用户。

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

二、使用LDAP Admin工具创建用户。
1、下载并运行LDAP Admin工具建立连接。

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

在group下创建posixGroup组。


在People下创建用户。

填入用户信息:

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

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

也可以使用匿名进行访问,但是无法进行用户创建。
2、创建两个OU,分别命名为:group、People

3、在group下创建一个POSIX Group

4、添加用户:


创建用户成功。
四、使用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



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


配置文件名:****
配置文件密码:********
配置openldap服务端,设置账户类型,并点击'save'。


添加Samba3模块:

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



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

新建立的用户的时候,会提示是否创建People,group的OU,点击'create'

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


添加用户:post,并设置密码:


再次点击'Unix',能看到post用户。并点击‘Save’

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

网友评论