Simple Open Liberty App with Open LDAP
Run this command to start your OpenLDAP Docker container. It will bind ports 389 and 689.
docker run -p 389:389 -p 689:689 --name ldaptest --detach osixia/openldap:1.2.2
Then start and configure the phpLDAPadmin to connect to your OpenLDAP container.
docker run -p 6443:443 --env PHPLDAPADMIN_LDAP_HOSTS=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" ldaptest) --detach osixia/phpldapadmin:0.7.2
Once the container is running it can be accessed at https://localhost:6443. You'll need to login with the admin credentials. By default these are Login DN: => cn=admin,dc=example,dc=org:admin
with Password: => admin
.
You'll need to add a new user that you can use to log into the application. This app is configured to use the inetOrgPerson
type.
- In the phpLDAPAdmin click the drop down menu for the DN you have set up. It will be
dc=example,dc=org
by default. - Go to
Create new entry here
and selectDefault
. Once inDefault
go to the drop down menu and select inetOrgPerson. - Set the
RDN
tocn
and add an entry for thecn
,sn
, andpassword
. - Click create and commit the entry.
You should now have a new user in your OpenLDAP registry.
To run the application use:
mvn clean install liberty:start
Connect to the application at http://localhost:9080/ldap-test/.
Enter your user's name and password into the login box. You'll need to use the whole name you entered earlier, e.g. cn=user,dc=example,dc=org
.
If all goes well you should see a message ending with: Hello, from a Servlet!
To stop the server use:
mvn liberty:stop