LDAP Configuration Reference
This document lists the LDAP settings of Txlog Server, and their values for the most common directory servers. For the procedure, see How to Configure LDAP Authentication. For an explanation, see LDAP Authentication.
Environment variables
| Variable | Required | Default | Description |
|---|---|---|---|
LDAP_HOST | Yes | - | Directory server hostname. |
LDAP_PORT | No | 389/636 | Port. Defaults to 636 when LDAP_USE_TLS=true. |
LDAP_USE_TLS | No | false | true connects with LDAPS. |
LDAP_BIND_DN | No | - | Service account DN. Do not set it for an anonymous bind. |
LDAP_BIND_PASSWORD | No | - | Service account password. |
LDAP_BASE_DN | Yes | - | Subtree that contains the users. |
LDAP_USER_FILTER | No | (uid=%s) | User search filter. %s is the username. |
LDAP_ADMIN_GROUP | Yes* | - | DN of the group with admin access. |
LDAP_VIEWER_GROUP | Yes* | - | DN of the group with read-only access. |
LDAP_GROUP_FILTER | No | (member=%s) | Membership filter. %s is the user's DN or uid. |
* At least one of LDAP_ADMIN_GROUP and LDAP_VIEWER_GROUP must be set, or the server does not start.
The server always examines the TLS certificate, and you cannot disable this. If your directory uses a private CA, install that CA on the Txlog Server host.
Minimal configurations
Without a service account. The directory must accept anonymous searches:
LDAP_HOST=ldap.example.com
LDAP_BASE_DN=ou=users,dc=example,dc=com
LDAP_ADMIN_GROUP=cn=admins,ou=groups,dc=example,dc=com
LDAP_VIEWER_GROUP=cn=viewers,ou=groups,dc=example,dc=comWith a service account. This is necessary for Active Directory and for directories with strict access policies:
LDAP_HOST=ldap.example.com
LDAP_BASE_DN=ou=users,dc=example,dc=com
LDAP_BIND_DN=cn=readonly,dc=example,dc=com
LDAP_BIND_PASSWORD=your_password
LDAP_ADMIN_GROUP=cn=admins,ou=groups,dc=example,dc=com
LDAP_VIEWER_GROUP=cn=viewers,ou=groups,dc=example,dc=comFilters by directory server
| Directory | LDAP_USER_FILTER | LDAP_GROUP_FILTER |
|---|---|---|
| OpenLDAP | (uid=%s) | (member=%s) |
| OpenLDAP with posixGroup | (uid=%s) | (memberUid=%s) |
| Active Directory | (sAMAccountName=%s) | (member=%s) |
| Active Directory (email) | (userPrincipalName=%s) | (member=%s) |
| FreeIPA | (uid=%s) | (member=%s) |
User filter, by login attribute
| Attribute | Filter | Used by |
|---|---|---|
uid | (uid=%s) | OpenLDAP, FreeIPA, 389 Directory |
sAMAccountName | (sAMAccountName=%s) | Active Directory |
userPrincipalName | (userPrincipalName=%s) | Active Directory, email as login |
mail | (mail=%s) | Any directory, email as login |
cn | (cn=%s) | Legacy schemas |
Group filter, by group objectClass
| objectClass | Member attribute | Filter | Value of %s |
|---|---|---|---|
groupOfNames | member | (member=%s) | the full DN |
groupOfUniqueNames | uniqueMember | (uniqueMember=%s) | the full DN |
group (AD) | member | (member=%s) | the full DN |
posixGroup | memberUid | (memberUid=%s) | only the uid |
Only a posixGroup uses the uid (john) and not a DN. If you use (member=%s) with a posixGroup, the filter finds no member. The log then shows "not a member of any authorized group" for all users.
If you do not know the filters of your directory, run scripts/ldap-discovery.sh or follow Discover LDAP Filters.
Container example
docker run -d -p 8080:8080 \
-e LDAP_HOST=ldap.example.com \
-e LDAP_BASE_DN=ou=users,dc=example,dc=com \
-e LDAP_BIND_DN=cn=readonly,dc=example,dc=com \
-e LDAP_BIND_PASSWORD=your_password \
-e LDAP_ADMIN_GROUP=cn=admins,ou=groups,dc=example,dc=com \
-e LDAP_VIEWER_GROUP=cn=viewers,ou=groups,dc=example,dc=com \
ghcr.io/txlog/server:mainIf the directory accepts anonymous searches, remove LDAP_BIND_DN and LDAP_BIND_PASSWORD.
Manual test of a configuration
These ldapsearch commands do the same operations as the server, in the same order. If they are successful, the configuration is correct:
# 1. Does the user search work, with the credentials the server would use?
ldapsearch -H ldap://ldap.example.com:389 \
-D "cn=readonly,dc=example,dc=com" -w "password" \
-b "ou=users,dc=example,dc=com" "(uid=testuser)"
# 2. Can the user themselves bind? (This is the authentication step.)
ldapsearch -H ldap://ldap.example.com:389 \
-D "uid=testuser,ou=users,dc=example,dc=com" -w "user_password" \
-b "ou=users,dc=example,dc=com" "(uid=testuser)" dn
# 3. Is the user in the group?
ldapsearch -H ldap://ldap.example.com:389 \
-D "cn=readonly,dc=example,dc=com" -w "password" \
-b "cn=admins,ou=groups,dc=example,dc=com" \
"(member=uid=testuser,ou=users,dc=example,dc=com)"To test an anonymous bind, remove -D and -w and add -x. If the commands fail with an anonymous bind, you must have a service account.
Troubleshooting
For each failed sign-in, the server log has a line Login failed (<code>): <reason>.
| In the log | Look at |
|---|---|
ldap_connection_error | LDAP_HOST, LDAP_PORT, firewall rules, certificate |
ldap_bind_error | LDAP_BIND_DN and LDAP_BIND_PASSWORD |
user not found | LDAP_BASE_DN and LDAP_USER_FILTER |
User bind failed for <dn> | the password of the user, or a locked account |
not a member of any authorized group | LDAP_GROUP_FILTER, and the group DNs |
Failed to check membership of <group> | the DN of that group, and the access to its subtree |
To also see the base DN and the full filter of each user search, set LOG_LEVEL=DEBUG. For LDAP result codes, see LDAP Error Codes.
