2019年7月22日 星期一

[OpenLDAP] Create an OpenLDAP container


 ASP.NET Core   Identity Server 4   OpenLDAP  


Introduction


We are going to create an OpenLDAP Authentication Server by Identity Server 4.
The architecture is as following.



Environment


docker-openldap 1.2.4 (OpenLDAP 2.4.47)


Implement


Pull docker image and run the container

osixia/openldap: Docker Hub | Github


Pull

$ docker pull osixia/openldap:1.2.4


Standard OpenLDAP with user: admin/admin at domain: example.org

$ docker run -e -d  -p 389:389 -p 636:636 --name <container_name> osixia/openldap:1.2.4


Specify the password for admin                                                              

$ docker run -e LDAP_ADMIN_PASSWORD="<new_password>" -d  -p 389:389 -p 636:636 --name <container_name> osixia/openldap:1.2.4


Specify the domain

$ docker run -e LDAP_ORGANISATION="jb" --env LDAP_DOMAIN="jb.org" --env LDAP_ADMIN_PASSWORD="12qwaszx" -d  -p 389:389 -p 636:636 --name <container_name> osixia/openldap:1.2.4



Search OU in Container

$ docker exec <container_name> ldapsearch -x -H ldap://localhost -b dc=example,dc=org -D "cn=admin,dc=example,dc=org" -w admin

Result:





Manage OpenLDAP: LdapAdmin

Here is an example to create a new OU by LDAP tool: LdapAdmin.

First create a New connection,




Enter the following host settings. Notice that the Admin account is default:

Username: cn=admin,dc=example,dc=org
Password: admin



The LDAP shows after we connect to the host.
Right click on the DC and add a new User as below,




We can also set the password for the new user.



Now search the new user by

$ docker exec <container_name> ldapsearch -x -H ldap://localhost -b uid=jblin,dc=example,dc=org -D "cn=admin,dc=example,dc=org" -w admin

Result:  






Reference







沒有留言:

張貼留言