This is an older version of Search Guard. Switch to Latest version
Active Directory and LDAP Authentication
Activating Authentication
To use Active Directory / LDAP for authentication first configure a respective authentication domain in the authc
section of sg_config
:
authc:
ldap:
enabled: true
order: 1
http_authenticator:
type: basic
challenge: true
authentication_backend:
type: ldap
config:
...
Afterwards add the connection settings for your Active Directory / LDAP server to the config section of the authentication domain, e.g.:
config:
enable_ssl: true
enable_start_tls: false
enable_ssl_client_auth: false
verify_hostnames: true
hosts:
- ldap.example.com:8389
bind_dn: cn=admin,dc=example,dc=com
password: passw0rd
Configuring Authentication
Authentication works by issuing an LDAP query containing the username against the user subtree of the LDAP tree.
Search Guard first takes the configured LDAP query, and replaces the placeholder {0}
with the username from the user’s credentials.
usersearch: '(sAMAccountName={0})'
Search Guard then issues this query against the user subtree (“userbase”). Currently the whole subtree beneath the configured userbase
is searched:
userbase: 'ou=people,dc=example,dc=com'
If the query was successful, Search Guard retrieves the username from the LDAP entry. You can specify which attribute from the LDAP entry Search Guard should use as the username:
username_attribute: uid
If this key is not set, or null, then the DN of the LDAP entry is used.
Configuration summary
Name | Description |
---|---|
userbase | Specifies the subtree in the directory where user information is stored |
usersearch | The actual LDAP query that Search Guard executes when trying to authenticate a user. The variable {0} is substituted with the username. |
username_attribute | Search Guard uses this attribute of the directory entry to look for the user name. If set to null, the DN is used (default). |
Complete authentication example
ldap:
enabled: true
order: 1
http_authenticator:
type: basic
challenge: true
authentication_backend:
type: ldap
config:
enable_ssl: true
enable_start_tls: false
enable_ssl_client_auth: false
verify_hostnames: true
hosts:
- ldap.example.com:636
bind_dn: cn=admin,dc=example,dc=com
password: password
userbase: 'ou=people,dc=example,dc=com'
usersearch: '(sAMAccountName={0})'
username_attribute: uid