安装步骤
安装docker
a.检查本地是否已安装docker
> docker --version
> Docker version 20.10.5, build 55c4c88
b.若已安装则跳过如下步骤
> brew install --cask --appdir=/Applications docker
==> Moving App 'Docker.app' to '/Applications/Docker.app'
🍺 docker was successfully installed!
> docker --version
使用docker 启动一个LDAP容器
> docker run -p 389:389 -p 636:636 --name my-openldap-container --detach osixia/openldap:1.4.0
默认管理员用户dn: “cn=admin,dc=example,dc=org”, password:“admin”
添加数据
方式一:加载ldif文件
- 新增文件myldap.ldif, 内容如下:
dn: dc=example,dc=org
objectClass: dcObject
objectClass: organization
o: Example, Inc.
dc: example
dn: cn=Manager,dc=example,dc=org
cn: Manager
objectClass: organizationalRole
dn: ou=People,dc=example,dc=org
ou: People
cn: People
objectClass: organizationalRole
objectClass: top
dn: cn=johnny,ou=People,dc=example,dc=org
mail: johnny@example.io
ou: Manager
cn: johnny
sn: johnny wang
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
userPassword:: ZXhhbXBsZTEyMw==
dn: cn=johnny2,ou=People,dc=example,dc=org
mail: johnny@example.io
ou: Manager
cn: johnny2
sn: johnny wang
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
userPassword:: ZXhhbXBsZTEyMw==
dn: cn=jenny,ou=People,dc=example,dc=org
mail: jenny@example.io
ou: Analyst
cn: jenny
sn: jenny liu
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
userPassword:: ZXhhbXBsZTEyMw==
dn: cn=oliver,ou=People,dc=example,dc=org
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
cn: oliver
sn: oliver wang
mail: oliver@example.io
ou: Modeler
userPassword:: ZXhhbXBsZTEyMw==
dn: ou=Groups,dc=example,dc=org
ou: Groups
objectClass: organizationalUnit
objectClass: top
dn: cn=itpeople,ou=Groups,dc=example,dc=org
cn: itpeople
objectClass: groupOfNames
objectClass: top
member: cn=johnny,ou=People,dc=example,dc=org
member: cn=oliver,ou=People,dc=example,dc=org
dn: cn=admin,ou=Groups,dc=example,dc=org
cn: admin
member: cn=jenny,ou=People,dc=example,dc=org
objectClass: groupOfNames
objectClass: top
- 将myldap.ldif文件拷贝到ldap容器中
> docker cp myldap.ldif ldap_contains_id:/
- 进入LDAP的docker容器加载数据
> docker exec -ti ldap_contains_id bash
> ldapadd -H ldap://127.0.0.1:389 -D "cn=admin,dc=example,dc=org" -w admin -f myldap.ldif -c
方式二:Apache Directory Studio
- **操作详细步骤:**https://blog.csdn.net/weixin_42176112/article/details/123308975?spm=1001.2014.3001.5501
方式三:python-ldap
- 脚本代码详见示例部分:https://blog.csdn.net/weixin_42176112/article/details/123308870?spm=1001.2014.3001.5501
|