How To Configure OpenLDAP on Docker in Minutes

preview_player
Показать описание
How to Setup and Configure Bitnami/OpenLDAP on Docker!

In this tutorial, we set up and configure Bitnami/OpenLDAP on a Docker environment. This guide is designed to provide you with clear, easy-to-follow instructions to get your LDAP server up and running smoothly on Docker.

Timestamps:

1:16 - SSH to Docker device
1:48 - Deploy your OpenLDAP Container
3:35 - Verify Container Deployment
3:42 - Install Nano on your OpenLDAP Container
4:31 - Verify SLAPD service is running
5:09 - Verify LDAP Configuration was accepted
6:06 - Using LDAPSearch Command to view created objects
8:25 - LDAPSearch Command Variations
9:16 - Change the password for a user
10:16 - Hashing Passwords for User creation files
11:02 - Adding additonal Users, Groups, OUs
13:17 - Using LDAPModify command to modify LDAP objectClass
15:14 - Deleting LDAP Objects (deleting a user)
15:56 - Connecting Portainer to OpenLDAP for authentication services
19:11 - Checking OpenLDAP Container Logs

Command and LDIF File Examples:

References:

# Installing OpenLDAP via Standard Docker Commands #

docker run --detach --hostname oldap5 --name openldap5 --network bridge\
--env LDAP_ROOT=dc=test,dc=com \
--env LDAP_ADMIN_USERNAME=ldap_admin \
--env LDAP_ADMIN_PASSWORD=adminpassword1 \
--env LDAP_ADMIN_DN=cn=ldap_admin,ou=users,dc=test,dc=com \
--env LDAP_USERS=customuser1 \
--env LDAP_PASSWORDS=custompassword1 \
--env LDAP_ALLOW_ANON_BINDING=no\
--env LDAP_USER_DC=users\
--env LDAP_GROUP_DC=groups\
-v openldap5:/bitnami/openldap\
-p 1389:1389 -p 1636:1636 \
bitnami/openldap:latest

Open a terminal session to the OpenLDAP container and install Nano:
docker exec -it -u root openldap5 /bin/bash
apt-get update
apt-get install nano

Verify the SLAPD service is running:
ps aux | grep slapd

Start OpenLDAP

Navigate to the database files folder to view the various database files:
cd /bitnami/openldap/slapd.d/cn\=config/

OpenLDAP Commands:

View the OpenLDAP database config file to verify your LDAP settings (most will fall under the "/bitnami/openldap/slapd.d/cn=config" directory):


Verify all entries below your base DN (See groups, users, OUs, etc.):
ldapsearch -x -H ldap://192.168.0.1:1389 -D "cn=ldap_admin,dc=test,dc=com" -W -b "dc=test,dc=com" -s sub "(objectclass=*)"

View users:
ldapsearch -x -H ldap://192.168.5.3:1389 -D "cn=ldap_admin,dc=techlogic,dc=com" -W -b "dc=techlogic,dc=com" -s sub "(objectclass=inetOrgPerson)"

# See specifics of a user:
ldapsearch -x -H ldap://192.168.0.1:1389 -D "cn=ldap_admin,dc=test,dc=com" -W -b "dc=test,dc=com" "(uid=customuser1)"

#Changing a user's password:

LDIF File Examples:

### Hashing your password to place in password field of your ldif file:
slappasswd -s yourpassword
# Creating OU, groups, and users with .ldif file (SEE BELOW FOR EXAMPLE .ldif File):


# Modifying existing LDAP Configuration:

####### LDIF FILE EXAMPLES [Remove fields that you do not need, this includes all sections in video] #######

# Create the "groups" Organizational Unit
dn: ou=groups,dc=test,dc=com
objectClass: organizationalUnit
ou: groups
description: Organizational Unit for Groups

objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
userPassword: {SSHA}THIS_IS_SHA_HASHED_PASSWORD

# Create the "Bind_Accounts" Group
dn: cn=bind_account,ou=groups,dc=test,dc=com
objectClass: top
objectClass: groupOfNames
cn: bind_account

# Add a new user to the "bind_account" group
dn: cn=bind_account,ou=groups,dc=test,dc=com
changetype: modify
add: member
member: uid=customuser1,ou=users,dc=test,dc=com

# Delete a user from a group
dn: cn=examplegroup,ou=groups,dc=example,dc=com
changetype: modify
delete: member
member: uid=exampleuser,ou=users,dc=example,dc=com

# Delete an object from LDAP: #

Helpful commands:

# To see the different options and command formats for ldapsearch
ldapsearch --help\

#Enter a shell within a container
docker exec -it container_name_or_id /bin/bash

#Copy files to container:
Рекомендации по теме
Комментарии
Автор

I'm going to have to try this in my lab. Thanks!

popadoc
Автор

Can you show us how to change the password for the admin account @6:00 into the video? For some reason its saying my password is invalid.

Daz