
How to Add Users in OpenLDAP
How to Add Users in OpenLDAP
OpenLDAP is an open-source implementation of the Lightweight Directory Access Protocol, useful for managing distributed directory information services. Adding users to your OpenLDAP server is a frequent administrative task that enables centralized management of user credentials and permissions.
Prerequisites
- Access to a server with OpenLDAP installed.
- Administrator privileges.
- Basic knowledge of the Linux command line.
Step-by-Step Instructions
1. Access Your Server
Log in to the server where OpenLDAP is running. You may connect through SSH:
ssh your_username@your_server_ip
2. Prepare LDIF File for New User
Create a new LDIF (LDAP Data Interchange Format) file which contains the user’s details. This file is used to add entries to the directory.
sudo vi add_user.ldif
Insert content similar to:
dn: uid=jdoe,ou=people,dc=example,dc=com
cn: John Doe
sn: Doe
objectClass: inetOrgPerson
uid: jdoe
userPassword: secret
3. Add the User to LDAP Directory
Load the LDIF file into your LDAP directory using the ldapadd
command:
ldapadd -x -D "cn=admin,dc=example,dc=com" -W -f add_user.ldif
You’ll be prompted to enter the LDAP admin password.
4. Verify the Addition
After adding the user, verify whether the user is present in the directory:
ldapsearch -xLLL -b "dc=example,dc=com" "uid=jdoe"
Troubleshooting
- Issue: Authentication failed when adding user.
Solution: Ensure you are using the correct admin credentials. - Issue: User already exists.
Solution: Check for existing user entries with the same UID and resolve duplicates.
Summary Checklist
- Prepare the LDIF file with user details.
- Add the user using
ldapadd
. - Verify the user addition with
ldapsearch
. - Troubleshoot any issues during user addition.
For further insights on OpenLDAP configuration, you may want to explore our guide on How to Install OpenLDAP on Linux.