How to Install OpenLDAP on Linux Mint Latest

OpenLDAP, a widely used open-source implementation of Lightweight Directory Access Protocol (LDAP), is a popular directory service solution used to manage user authentication, groups, security policies, directory structure, and more. In this tutorial, we’ll guide you through the process of installing OpenLDAP on Linux Mint Latest.

Before we proceed kindly make sure that you have sudo access or you are logged in as a root user.

Prerequisites

Install OpenLDAP

Here are the steps to install OpenLDAP on Linux Mint Latest:

Step 1: Install Dependencies

The first step is to install the dependencies required by OpenLDAP:

sudo apt-get update
sudo apt-get install -y libldap2-dev ldap-utils

Step 2: Install OpenLDAP Server

sudo apt-get install -y slapd ldap-utils

Step 3: Configuration

sudo nano /etc/ldap/ldap.conf
BASE dc=example,dc=com
URI ldap://127.0.0.1

Step 4: Verify OpenLDAP Installation

You can run the following command to verify that the OpenLDAP services are running:

sudo systemctl status slapd

If the OpenLDAP service is started, you will get output similar to the following:

● slapd.service - LSB: OpenLDAP standalone server (Lightweight Directory Access Protocol)
   Loaded: loaded (/etc/init.d/slapd; generated)
   Active: active (running) since Fri 2021-03-19 14:03:05 IST; 19h ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 6 (limit: 19068)
   Memory: 11.1M
   CGroup: /system.slice/slapd.service
           └─3038 /usr/sbin/slapd -d 0

Step 5: Create a User

nano user.ldif

Contents:

dn: uid=john,ou=People,dc=example,dc=com 
objectClass: inetOrgPerson 
objectClass: posixAccount 
objectClass: shadowAccount 
uid: john 
sn: Doe 
givenName: John 
cn: John Doe 
displayName: John Doe 
uidNumber: 10000 
gidNumber: 10000 
userPassword: {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g= 
gecos: John Doe 
loginShell: /bin/bash 
homeDirectory: /home/john
sudo ldapadd -x -D cn=admin,dc=example,dc=com -W -f user.ldif

Step 6: Verify the User Creation

You can run the following command to verify whether the user creation is successful.

sudo ldapsearch -x -b dc=example,dc=com -h localhost -D 'cn=admin,dc=example,dc=com' -w password "(uid=john)"

Output:

Version: 1
dn: uid=john,ou=People,dc=example,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
uid: john
cn: John Doe
sn: Doe
givenName: John
displayName: John Doe
gecos: John Doe
loginShell: /bin/bash
homeDirectory: /home/john
uidNumber: 10000
gidNumber: 10000
userPassword:: e1NTSEF9VzZwaDVNbTVQejhHZ2lVTGJQZ3pHMzdtajlnPQ==
shadowLastChange: 18108
shadowMax: 99999
shadowWarning: 7

Congratulations! You have successfully installed and configured OpenLDAP on your Linux Mint Latest system.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!