Start a conversation

How to create a simple LDAP Database on Linux

Creating a simple LDAP Database on Linux.

Installing and configuring slapd

We are going to use OpenLDAP(slapd) to build a LDAP database accessible for the security module WITHOUT simulating an Active Directory. This tutorial will create an LDAP server and a single user for access.


Image 01: Installing slapd.

In a Debian-based system, we need to use apt-get to retrieve and install slapd.


Image 02: Using dpkg-reconfigure to change slapd settings.

After the installation, we must configure the settings for the slapd. To do so, we must use dpkg-reconfigure to build.


Image 03: Configuring slapd.

Select the "No" option and press Enter to continue.


Image 04: Defining domain name.

Choose your domain name.


Image 05: Defining organization name.

Type the organization name and press Enter to continue.


Image 06: Setting up admin password.

Define the admin password and press Enter to confirm it.


Image 07: Defining database engine backend.

This screen allows us to choose the Database backend. We recommend you to use HDB. Press enter to proceed and then choose to clean your previous DB.


Image 08: Purging previous DB.


Image 09: Moving old files.

Adding a new user

First of all, you must create a LDIF file with the info about the user on it:
user@computer:~$ touch hbarros.ldif

This is the content we are using for this sample file:


# Object 1: uid=hbarros,dc=admartini,dc=scriptcase,dc=info
dn: uid=hbarros,dc=admartini,dc=scriptcase,dc=info
objectclass: account
objectclass: simpleSecurityObject
objectclass: top
uid: hbarros
userpassword: {MD5}6jAUXhUfuutm7cbFC6oVUA==


Now we are ready to put it on the database itself.

Get admin rights:
user@computer:~$ su

Stop the lapd service:
root@computer:/home/user# /etc/init.d/sladp stop

Use slapadd to import the file:
root@computer:/home/user# slapadd -l /home/user/hbarros.ldif

Restart the service.
root@computer:/home/user# /etc/init.d/slapd start




This tutorial created a LDAP authentication environment. The authentication data for this example are:

DN DC=admartini,DC=scriptcase,DC=info
User Name UID=hbarros,DC=scriptcase,DC=info
Choose files or drag and drop files
Was this article helpful?
  1. Jefferson Albuquerque

  2. Posted
  3. Updated



    muito bom