Configuring LDAP authentication lets a self-hosted Grafana server accept directory usernames and passwords instead of only local Grafana accounts. Directory login keeps password policy and account lifecycle in the LDAP server while Grafana still controls dashboards, folders, data sources, and organization roles.
Packaged Linux installs read LDAP settings through two configuration layers. /etc/grafana/grafana.ini enables the LDAP authenticator, and /etc/grafana/ldap.toml defines the directory host, bind account, user search, attributes, and group mappings.
Debian, Ubuntu, and RPM package installs commonly run as the grafana-server systemd service with configuration under /etc/grafana. Restart Grafana after changing /etc/grafana/ldap.toml because Grafana reads the LDAP file during startup, and the first successful LDAP login creates the Grafana user when allow_sign_up is enabled.
Related: How to install Grafana on Ubuntu
Related: How to configure HTTPS for Grafana
Prepare the directory hostname, encrypted port, bind DN, bind password, user search filter, user search base, group DNs, and the LDAP attributes that hold username, email, name, and group membership. The sample values use ldap.example.net and dc=example,dc=net placeholders.
$ sudoedit /etc/grafana/grafana.ini
[auth.ldap] enabled = true config_file = /etc/grafana/ldap.toml allow_sign_up = true
Set allow_sign_up to false only when matching Grafana users already exist. With true, Grafana creates the local user after successful LDAP authentication.
$ sudoedit /etc/grafana/ldap.toml
servers = [
{ host = "ldap.example.net", port = 636, use_ssl = true, start_tls = false, ssl_skip_verify = false, bind_dn = "cn=grafana-reader,ou=service-accounts,dc=example,dc=net", bind_password = "replace-with-bind-password", search_filter = "(uid=%s)", search_base_dns = ["ou=people,dc=example,dc=net"], attributes = { name = "givenName", surname = "sn", username = "uid", member_of = "memberOf", email = "mail" }, group_mappings = [{ group_dn = "cn=grafana-admins,ou=groups,dc=example,dc=net", org_role = "Admin", grafana_admin = true }, { group_dn = "cn=grafana-editors,ou=groups,dc=example,dc=net", org_role = "Editor" }, { group_dn = "*", org_role = "Viewer" }] }
]
For Active Directory, the search filter often uses (sAMAccountName=%s) and the email attribute often uses mail. For STARTTLS on port 389, keep use_ssl enabled and set start_tls to true.
$ sudo chown root:grafana /etc/grafana/ldap.toml
$ sudo chmod 0640 /etc/grafana/ldap.toml
The file contains a bind password unless the value is moved to Grafana environment-variable expansion such as ${LDAP_BIND_PASSWORD}. Do not make /etc/grafana/ldap.toml world-readable.
$ sudo systemctl restart grafana-server
$ sudo systemctl is-active grafana-server active
$ sudo journalctl --unit=grafana-server --grep='LDAP enabled' --no-pager Jun 19 22:25:28 grafana.example.net grafana[1428]: logger=ldap level=info msg="LDAP enabled, reading config file" file=/etc/grafana/ldap.toml
This log line appears when LDAP is enabled and Grafana can read the configured /etc/grafana/ldap.toml path.
$ curl -sS -u admin https://grafana.example.net/api/users/lookup?loginOrEmail=alice
Enter host password for user 'admin':
{"id":2,"email":"alice@example.net","name":"Alice Example","login":"alice","orgId":1,"isGrafanaAdmin":false,"authLabels":["LDAP"]}
Replace alice with a user who has already signed in once. The authLabels field shows LDAP when the account came through LDAP authentication.