## 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.

![](http://34.207.224.239:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbFlZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--e6e875ab9d82b894e252a29cd75f19ad3b55656f/image-955f43614b.jpg)

Image 01: Installing slapd.

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

![](http://34.207.224.239:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbGdZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--b723af69e470ce53adf01e6283e50e8e81e3c598/image-ebbc8b883f.jpg)

  
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.

![](http://34.207.224.239:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbHNZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--a6c30e70696cca62ed0739f203a422852514f928/image-7bff5cf655.jpg)

  
Image 03: Configuring slapd.

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

![](http://34.207.224.239:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbWdZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--8aed32c769daefa27ffdeff90bd3906026172455/image-272954f02b.jpg)

  
Image 04: Defining domain name.

Choose your domain name.

![](http://34.207.224.239:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbWtZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--424dae87b2c7282cedab17dce742950d739bc241/image-b94e58448f.jpg)

  
Image 05: Defining organization name.

Type the organization name and press Enter to continue.

![](http://34.207.224.239:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbXNZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--aada5e24dc090bc1f73b6ecb3c03074620de470e/image-8eaacc4378.jpg)

  
Image 06: Setting up admin password.

Define the admin password and press Enter to confirm it.

![](https://desk.zoho.com/DocsDisplay?zgId=716875472&mode=inline&blockId=0a12ge66920b51ada4c588dca1ad7e1520c36)

  
Image 07: Purging previous DB.

![](https://desk.zoho.com/DocsDisplay?zgId=716875472&mode=inline&blockId=0a12gefb81cecc004442c9253c5685b316232)

  
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 |