## 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/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBanNZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--37fd7f83b5f20c7fa112e1bcc8c52715965db191/image-220bbd831b.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/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBajBZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--d65fa5f5fe714d8c804a6488e37468a14dff2999/image-fd307aea1c.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/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBa0VZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--89870ba5fe64ec7e9784c0e7ea4c95125666b259/image-4e21fae25b.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/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBa1FZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--b632058a61a6a8e6414d4364dccd3275e804a9de/image-ce38642eee.jpg)

  
Image 04: Defining domain name.

Choose your domain name.

![](http://34.207.224.239:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBa2NZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--82ccb6811628f3a6e55e27bda6a51df3b566e605/image-088f34df85.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/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBa29ZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--a143434c3dc619ffad5244f6342742dd3ac97dc8/image-969e7fc5fa.jpg)

Image 06: Setting up admin password.

Define the admin password and press Enter to confirm it.

![](http://34.207.224.239:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBazRZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--cf45a532c560f9d71646d482bd1509151e7181e0/image-6dffd90716.jpg)

Image 07: Purging previous DB.

![](http://34.207.224.239:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBbElZIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--43b69d479241c86dfc0045735815cdb4d78985de/image-a30dc16c98.jpg)

  
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 |