1# LDAP BindDN23maddy supports authentication via LDAP using DN binding. Passwords are verified4by the LDAP server.56maddy needs to know the DN to use for binding. It can be obtained either by7directory search or template .89Note that storage backends conventionally use email addresses, if you use10non-email identifiers as usernames then you should map them onto11emails on delivery by using `auth_map` (see documentation page for used storage backend).1213auth.ldap also can be a used as a table module. This way you can check14whether the account exists. It works only if DN template is not used.1516```17auth.ldap {18 urls ldap://maddy.test:3891920 # Specify initial bind credentials. Not required ('bind off')21 # if DN template is used.22 bind plain "cn=maddy,ou=people,dc=maddy,dc=test" "123456"2324 # Specify DN template to skip lookup.25 dn_template "cn={username},ou=people,dc=maddy,dc=test"2627 # Specify base_dn and filter to lookup DN.28 base_dn "ou=people,dc=maddy,dc=test"29 filter "(&(objectClass=posixAccount)(uid={username}))"3031 tls_client { ... }32 starttls off33 debug off34 connect_timeout 1m35}36```37```38auth.ldap ldap://maddy.test.389 {39 ...40}41```4243## Configuration directives4445### urls _servers..._4647**Required.**4849URLs of the directory servers to use. First available server50is used - no load-balancing is done.5152URLs should use `ldap://`, `ldaps://`, `ldapi://` schemes.5354---5556### bind `off` | `unauth` | `external` | `plain` _username_ _password_5758Default: `off`5960Credentials to use for initial binding. Required if DN lookup is used.6162`unauth` performs unauthenticated bind. `external` performs external binding63which is useful for Unix socket connections (`ldapi://`) or TLS client certificate64authentication (cert. is set using tls_client directive). `plain` performs a65simple bind using provided credentials.6667---6869### dn_template _template_7071DN template to use for binding. `{username}` is replaced with the72username specified by the user.7374---7576### base_dn _dn_7778Base DN to use for lookup.7980---8182### filter _str_8384DN lookup filter. `{username}` is replaced with the username specified85by the user.8687Example:8889```90(&(objectClass=posixAccount)(uid={username}))91```9293Example (using ActiveDirectory):9495```96(&(objectCategory=Person)(memberOf=CN=user-group,OU=example,DC=example,DC=org)(sAMAccountName={username})(!(UserAccountControl:1.2.840.113556.1.4.803:=2)))97```9899Example:100101```102(&(objectClass=Person)(mail={username}))103```104105---106107### starttls _bool_108Default: `off`109110Whether to upgrade connection to TLS using STARTTLS.111112---113114### tls_client { ... }115116Advanced TLS client configuration. See [TLS configuration / Client](/reference/tls/#client) for details.117118---119120### connect_timeout _duration_121Default: `1m`122123Timeout for initial connection to the directory server.124125---126127### request_timeout _duration_128Default: `1m`129130Timeout for each request (binding, lookup).