LDAP Authentication

LeweAuto can authenticate users against an LDAP directory such as OpenLDAP or Active Directory. LDAP is authentication only: accounts, roles, groups and vehicle assignments stay in LeweAuto and nothing is copied from the directory.

How it works

  • Set LDAP_YES=1 in .env.<target> to enable LDAP for all users.
  • The built-in admin account always authenticates against the LeweAuto database, so an administrator can still sign in when the directory is unavailable.
  • Users must already exist in LeweAuto. The username must match the attribute configured in LDAP_USER_ATTR (uid by default, or sAMAccountName with LDAP_ADS=1).
  • The login page tells users that LDAP authentication is active.
  • Password changes and password resets for external accounts are handled by the directory, not by LeweAuto.

Configuration

LDAP_YES=1
LDAP_ADS=0
LDAP_HOST=ldap.example.com
LDAP_PORT=389
LDAP_PASS=secret_password
LDAP_DIT=cn=read-only-admin,dc=example,dc=com
LDAP_SBASE=dc=example,dc=com
LDAP_TLS=0
LDAP_CHECK_ANONYMOUS_BIND=0
LDAP_SEARCH_BIND=0
LDAP_USER_ATTR=uid
LDAP_TIMEOUT=5
Variable Meaning
LDAP_ADS 1 for Active Directory; defaults the user attribute to sAMAccountName
LDAP_DIT / LDAP_PASS Bind account used to search the directory
LDAP_SBASE Search base
LDAP_TLS 0 none, 1 STARTTLS on LDAP_PORT (usually 389), 2 implicit TLS/LDAPS (usually 636)
LDAP_CHECK_ANONYMOUS_BIND Test an anonymous bind before the real bind
LDAP_SEARCH_BIND Bind as the user after the search instead of only searching
LDAP_USER_ATTR Attribute that holds the username
LDAP_TIMEOUT Network timeout in seconds

Do not put comments on the same line as a value. Keep these settings in .env so they survive upgrades.

Test the connection

The test tool accepts a flag:

npm run test:auth -- --ldap

This checks the directory login in addition to the local tests.

LDAP is disabled for the admin account on purpose. Keep a working local administrator password even when the whole team uses the directory.

Last updated: