Creating a LDAP server for your development environment in 5 minutes

I am currently working on a plugin that needs to receive some information from an LDAP/Active Directory using JNDI. That’s why I needed to set up a directory server in a short time and I didn’t want to waste much effort for here.

Luckily for me the Apache Directory Studio saved my day and allowed me to set up everything I needed in a few minutes.

Short and sweet: In this tutorial I’m going to show you how to configure everything you need in your Eclipse IDE and finally how to query the created LDAP server with a tiny java client using JNDI.

Start your LDAP server by rightclick and run .. after a short time the server’s status should have changed to “started”

Viewing the LDAP server status in Eclipse

If you take a look at the server’s current configuration you’ll see that the server is configured for the host name ldap.example.com

Creating a connection to the server

We need a connection for the following data import and to query our directory server

Just right-click on the server in the server view and select LDAP-Browser > Create a connection and let the IDE switch to the LDAP Perspective

In the LDAP perspective there’s the LDAP Browser, an outline for the directory structure, the connection and server views and the directory logs

Import sample data from a LDIF file

Now we need some data in our directory server – we do not query him for fun!

We’re going to import some data from an LDIF file .. just copy the following content and save it to a file and open it in the perspectiv. It is important that the last line in the LDIF file is an empty line/newline.