Skip to content

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 ​

VariableRequiredDefaultDescription
LDAP_HOSTYes-Directory server hostname.
LDAP_PORTNo389/636Port. Defaults to 636 when LDAP_USE_TLS=true.
LDAP_USE_TLSNofalsetrue connects with LDAPS.
LDAP_BIND_DNNo-Service account DN. Do not set it for an anonymous bind.
LDAP_BIND_PASSWORDNo-Service account password.
LDAP_BASE_DNYes-Subtree that contains the users.
LDAP_USER_FILTERNo(uid=%s)User search filter. %s is the username.
LDAP_ADMIN_GROUPYes*-DN of the group with admin access.
LDAP_VIEWER_GROUPYes*-DN of the group with read-only access.
LDAP_GROUP_FILTERNo(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:

bash
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=com

With a service account. This is necessary for Active Directory and for directories with strict access policies:

bash
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=com

Filters by directory server ​

DirectoryLDAP_USER_FILTERLDAP_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 ​

AttributeFilterUsed 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 ​

objectClassMember attributeFilterValue of %s
groupOfNamesmember(member=%s)the full DN
groupOfUniqueNamesuniqueMember(uniqueMember=%s)the full DN
group (AD)member(member=%s)the full DN
posixGroupmemberUid(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 ​

bash
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:main

If 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:

bash
# 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 logLook at
ldap_connection_errorLDAP_HOST, LDAP_PORT, firewall rules, certificate
ldap_bind_errorLDAP_BIND_DN and LDAP_BIND_PASSWORD
user not foundLDAP_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 groupLDAP_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.