OpenLDAP Integration
This guide provides a comprehensive walkthrough for setting up OpenLDAP authentication with Open WebUI. It covers creating a test OpenLDAP server using Docker, seeding it with sample users, configuring Open WebUI to connect to it, and troubleshooting common issues.
1. Setting Up OpenLDAP with Docker
The easiest way to get a test OpenLDAP server running is by using Docker. This docker-compose.yml file will create an OpenLDAP container and an optional phpLDAPadmin container for a web-based GUI.
version: "3.9"
services:
ldap:
image: osixia/openldap:1.5.0
container_name: openldap
environment:
LDAP_ORGANISATION: "Example Inc"
LDAP_DOMAIN: "example.org"
LDAP_ADMIN_PASSWORD: admin
LDAP_TLS: "false"
volumes:
- ./ldap/var:/var/lib/ldap
- ./ldap/etc:/etc/ldap/slapd.d
ports:
- "389:389"
networks: [ldapnet]
phpldapadmin:
image: osixia/phpldapadmin:0.9.0
environment:
PHPLDAPADMIN_LDAP_HOSTS: "ldap"
ports:
- "6443:443"
networks: [ldapnet]
networks:
ldapnet:
driver: bridge
- The
osixia/openldapimage automatically creates a basic organization structure with justLDAP_DOMAINandLDAP_ADMIN_PASSWORD. - The
osixia/phpldapadminimage provides a web interface for managing your LDAP directory, accessible athttps://localhost:6443.
Run docker-compose up -d to start the containers. Confirm that the LDAP server has started by checking the logs: docker logs openldap. You should see a "started slapd" message.
2. Seeding a Sample User (LDIF)
To test the login, you need to add a sample user to the LDAP directory. Create a file named seed.ldif with the following content:
dn: ou=users,dc=example,dc=org
objectClass: organizationalUnit
ou: users
dn: uid=jdoe,ou=users,dc=example,dc=org
objectClass: inetOrgPerson
cn: John Doe
sn: Doe
uid: jdoe
mail: jdoe@example.org
userPassword: {PLAIN}password123
Note on Passwords: The userPassword field is set to a plain text value for simplicity in this test environment. In production, you should always use a hashed password. You can generate a hashed password using slappasswd or openssl passwd. For example:
# Using slappasswd (inside the container)
docker exec openldap slappasswd -s your_password
# Using openssl
openssl passwd -6 your_password
Copy the LDIF file into the container and use ldapadd to add the entry:
docker cp seed.ldif openldap:/seed.ldif
docker exec openldap ldapadd -x -D "cn=admin,dc=example,dc=org" -w admin -f /seed.ldif
A successful operation will show an "adding new entry" message.
3. Verifying the LDAP Connection
Before configuring Open WebUI, verify that the LDAP server is accessible and the user exists.
ldapsearch -x -H ldap://localhost:389 \
-D "cn=admin,dc=example,dc=org" -w admin \
-b "dc=example,dc=org" "(uid=jdoe)"
If the command returns the jdoe user entry, your LDAP server is ready.
4. Configuring Open WebUI
Now, configure your Open WebUI instance to use the LDAP server for authentication.
Environment Variables
Set the following environment variables for your Open WebUI instance.
Open WebUI reads these environment variables only on the first startup. Subsequent changes must be made in the Admin settings panel of the UI unless you have ENABLE_PERSISTENT_CONFIG=false.
# Enable LDAP
ENABLE_LDAP="true"
# --- Server Settings ---
LDAP_SERVER_LABEL="OpenLDAP"
LDAP_SERVER_HOST="localhost" # Or the IP/hostname of your LDAP server
LDAP_SERVER_PORT="389" # Use 389 for plaintext/StartTLS, 636 for LDAPS
LDAP_USE_TLS="false" # Set to "true" for LDAPS or StartTLS
LDAP_VALIDATE_CERT="false" # Set to "true" in production with valid certs
# --- Bind Credentials ---
LDAP_APP_DN="cn=admin,dc=example,dc=org"
LDAP_APP_PASSWORD="admin"
# --- User Schema ---
LDAP_SEARCH_BASE="dc=example,dc=org"
LDAP_ATTRIBUTE_FOR_USERNAME="uid"
LDAP_ATTRIBUTE_FOR_MAIL="mail"
# LDAP_SEARCH_FILTER is optional and used for additional filtering conditions.
# The username filter is automatically added by Open WebUI, so do NOT include
# user placeholder syntax like %(user)s or %s - these are not supported.
# Leave empty for simple setups, or add group membership filters, e.g.:
# LDAP_SEARCH_FILTER="(memberOf=cn=allowed-users,ou=groups,dc=example,dc=org)"
UI Configuration
Alternatively, you can configure these settings directly in the UI:
- Log in as an administrator.
- Navigate to Settings > General.
- Enable LDAP Authentication.
- Fill in the fields corresponding to the environment variables above.
- Save the settings and restart Open WebUI.
5. Logging In
Open a new incognito browser window and navigate to your Open WebUI instance.
- Login ID:
jdoe - Password:
password123(or the password you set)
Upon successful login, a new user account with "User" role will be created automatically in Open WebUI. An administrator can later elevate the user's role if needed.
6. Troubleshooting Common Errors
Here are solutions to common errors encountered during LDAP integration.