$ docker run -itd --name ldap-test01 -p 40000:389 -p 40001:80 ubuntu:16.04 /bin/bash

$ docker cp sources.list ldap-test01:/etc/apt/sources.list

apt-get update

apt-get install slapd ldap-utils -y # 安装相关的包

设置密码

dpkg-reconfigure slapd #配置ldap

Omit OpenLDAP server configuration? [yes/no] # no

DNS domain name: baidu.com

Organization name: baidu

设置密码

Database backend to use: 3

Do you want the database to be removed when slapd is purged? [yes/no] yes

Allow LDAPv2 protocol? [yes/no] yes

/etc/init.d/slapd start

cat /etc/ldap/slapd.d/cn\=config/olcDatabase\={1}mdb.ldif # 相关的内容


AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.

CRC32 60751870

dn: olcDatabase={1}mdb
objectClass: olcDatabaseConfig
objectClass: olcMdbConfig
olcDatabase: {1}mdb
olcDbDirectory: /var/lib/ldap
olcSuffix: dc=baidu,dc=com
olcAccess: {0}to attrs=userPassword by self write by anonymous auth by non
e
olcAccess: {1}to attrs=shadowLastChange by self write by
read
olcAccess: {2}to by read
olcLastMod: TRUE
olcRootDN: cn=admin,dc=baidu,dc=com
olcRootPW:: e1NTSEF9MG5YT2lrRmRyOURicEhxeEl0MU5paWlCaC8xTU1UQXo=
olcDbCheckpoint: 512 30
olcDbIndex: objectClass eq
olcDbIndex: cn,uid eq
olcDbIndex: uidNumber,gidNumber eq
olcDbIndex: member,memberUid eq
olcDbMaxSize: 1073741824
structuralObjectClass: olcMdbConfig
entryUUID: 003cfcec-cac2-1038-96ab-db71de40cffc
creatorsName: cn=config
createTimestamp: 20190222074834Z
entryCSN: 20190222074834.725975Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20190222074834Z

ldapwhoami -H ldap:// -x # 测试是否正常

docker 搭建ldap

第2步 - 安装和配置phpLDAPadmin Web界面

apt-get install phpldapadmin -y

apt-get install vim -y

vim /etc/phpldapadmin/config.php # 修改相关内容


$servers->setValue('server','base',array('dc=baidu,dc=com'));

$config->custom->appearance['hide_template_warning'] = true;

/etc/init.d/apache2 restart

http://127.0.0.1:40001/phpldapadmin # 打开网址

cn=admin,dc=baidu,dc=com # 账号

docker 搭建ldap_第1张图片

登录成功
docker 搭建ldap_第2张图片

创建OU
docker 搭建ldap_第3张图片

docker 搭建ldap_第4张图片

创建名字为users
docker 搭建ldap_第5张图片

再创建UID
选择defualt #
查找 inetOrgPerson

docker 搭建ldap_第6张图片

选择 rdn
必填写
cn sn Password User Name

docker 搭建ldap_第7张图片

点外卖的小伙伴可以能进群
docker 搭建ldap_第8张图片