How to create a simple LDAP Database on Linux

Á

Álvaro Moura

Last updated on Jul 6, 2026

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: Purging previous DB.

Image 08: 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=lpessoa,dc=scriptcase,dc=info dn: uid=hbarros,dc=lpessoa,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

Results

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

Domain LPESSOA
DN DC=lpessoa,DC=scriptcase,DC=info
User Name UID=hbarros,DC=scriptcase,DC=info