Skip to content

Installing OpenLDAP

Dennis Stumm edited this page Jul 1, 2020 · 1 revision

Install the necessary packages:

sudo apt-get install slapd ldap-utils

Reconfigure the slapd package configuration (this can be done multiple times if you wan't to restart):

sudo dpkg-reconfigure slapd
# Omit OpenLDAP server configuration => No
# DNS domain name => local.com
# Organization name => thm
# Administrator password => your password e.g. secret
# Database backend to use => MDB
# Do you want the database to be removed when slapd is purged => yes
# Mobe old database => yes

To check the configration execute following command:

ldapsearch -x -b "dc=local,dc=com"

You should see something like following:

# extended LDIF
#
# LDAPv3
# base <dc=local,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# local.com
dn: dc=local,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: thm
dc: local

# admin, local.com
dn: cn=admin,dc=local,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator

# search result
search: 2
result: 0 Success

# numResponses: 3
# numEntries: 2

Finally add a new organizational unit and a user with the following commands:

ldapadd -D "cn=admin,dc=local,dc=com" -W
# Enter following lines and modify how you want
Enter LDAP Password: 
dn: ou=people,dc=local,dc=com
objectClass: organizationalUnit
ou: people
# 2xEnter
adding new entry "ou=people,dc=local,dc=com"

dn: uid=mstt,ou=people,dc=local,dc=com     
objectClass: inetOrgPerson
uid: mstt
mail: max.muster@local.com
cn: Max Mustermann
givenName: Max
sn: Mustermann
# 2xEnter
adding new entry "uid=mstt,ou=people,dc=local,dc=com"
#crtl+d

Finally change the password of the user:

ldappasswd -D "cn=admin,dc=local,dc=com" -W -S "uid=mstt,ou=people,dc=local,dc=com"

And don't forget to adjust the .env file like it is in the .sample.env.

Clone this wiki locally