2016-10-21 17:01:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								+++
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								title = "LDAP Authentication"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								description = "Grafana LDAP Authentication Guide "
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								keywords = ["grafana", "configuration", "documentation", "ldap"]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								type = "docs"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[menu.docs]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								name = "LDAP Authentication"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								identifier = "ldap"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								parent = "admin"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								weight = 2
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								+++
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-21 17:01:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# LDAP Authentication
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-10 03:25:42 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Grafana (2.1 and newer) ships with a strong LDAP integration feature. The LDAP integration in Grafana allows your
							 
						 
					
						
							
								
									
										
										
										
											2015-08-12 22:30:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Grafana users to login with their LDAP credentials. You can also specify mappings between LDAP
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								group memberships and Grafana Organization user roles.
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Configuration
 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-21 17:01:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								You turn on LDAP in the [main config file ]({{< relref "configuration.md#auth-ldap" >}} ) as well as specify the path to the LDAP
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								specific configuration file (default: `/etc/grafana/ldap.toml` ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								### Example config
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```toml
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Set to true to log user information returned from LDAP
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								verbose_logging = false
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[[servers]]
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Ldap server host (specify multiple hosts space separated)
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								host = "127.0.0.1"
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Default port is 389 or 636 if use_ssl = true
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								port = 389
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Set to true if ldap server supports TLS
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								use_ssl = false
							 
						 
					
						
							
								
									
										
										
										
											2016-09-10 15:40:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Set to true if connect ldap server with STARTTLS pattern (create connection in insecure, then upgrade to secure connection with TLS)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								start_tls = false
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# set to true if you want to skip ssl cert validation
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-16 17:57:59 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								ssl_skip_verify = false
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# set to the path to your root CA certificate or leave unset to use system defaults
 
							 
						 
					
						
							
								
									
										
										
										
											2017-04-06 15:53:11 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# root_ca_cert = "/path/to/certificate.crt"
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Search user bind dn
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								bind_dn = "cn=admin,dc=grafana,dc=org"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Search user bind password
 
							 
						 
					
						
							
								
									
										
										
										
											2016-12-22 05:02:33 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;"""
 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								bind_password = 'grafana'
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# User search filter, for example "(cn=%s)" or "(sAMAccountName=%s)" or "(uid=%s)"
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								search_filter = "(cn=%s)"
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# An array of base dns to search through
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								search_base_dns = ["dc=grafana,dc=org"]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# In POSIX LDAP schemas, without memberOf attribute a secondary query must be made for groups.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# This is done by enabling group_search_filter below. You must also set member_of= "cn"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# in [servers.attributes] below.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Group search filter, to retrieve the groups of which the user is a member (only set if memberOf attribute is not available)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# group_search_filter = "(&(objectClass=posixGroup)(memberUid=%s))"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## An array of the base DNs to search through for groups. Typically uses ou=groups
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# group_search_base_dns = ["ou=groups,dc=grafana,dc=org"]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Specify names of the ldap attributes your ldap uses
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								[servers.attributes]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								name = "givenName"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								surname = "sn"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								username = "cn"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								member_of = "memberOf"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								email =  "email"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# Map ldap groups to grafana org roles
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								[[servers.group_mappings]]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								group_dn = "cn=admins,dc=grafana,dc=org"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								org_role = "Admin"
							 
						 
					
						
							
								
									
										
										
										
											2017-05-02 22:45:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# The Grafana organization database id, optional, if left out the default org (id 1) will be used.  Setting this allows for multiple group_dn's to be assigned to the same org_role provided the org_id differs
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# org_id = 1
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-12 10:46:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[[servers.group_mappings]]
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								group_dn = "cn=users,dc=grafana,dc=org"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								org_role = "Editor"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[[servers.group_mappings]]
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# If you want to match all (or no ldap groups) then you can use wildcard
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								group_dn = "*"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								org_role = "Viewer"
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Bind & Bind Password
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-12 10:46:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								By default the configuration expects you to specify a bind DN and bind password. This should be a read only user that can perform LDAP searches.
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								When the user DN is found a second bind is performed with the user provided username &  password (in the normal Grafana login form).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-06 01:01:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```bash
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								bind_dn = "cn=admin,dc=grafana,dc=org"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								bind_password = "grafana"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-12 10:46:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### Single Bind Example
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-12 02:58:30 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								If you can provide a single bind expression that matches all possible users, you can skip the second bind and bind against the user DN directly.
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								This allows you to not specify a bind_password in the configuration file.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-10-06 01:01:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```bash
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								bind_dn = "cn=%s,o=users,dc=grafana,dc=org"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-12 10:46:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								In this case you skip providing a `bind_password`  and instead provide a `bind_dn`  value with a `%s`  somewhere. This will be replaced with the username entered in on the Grafana login page.
							 
						 
					
						
							
								
									
										
										
										
											2015-10-22 13:09:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								The search filter and search bases settings are still needed to perform the LDAP search to retrieve the other LDAP information (like LDAP groups and email).
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## POSIX schema (no memberOf attribute)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								If your ldap server does not support the memberOf attribute add these options:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```toml
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## Group search filter, to retrieve the groups of which the user is a member (only set if memberOf attribute is not available)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								group_search_filter = "(& (objectClass=posixGroup)(memberUid=%s))"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## An array of the base DNs to search through for groups. Typically uses ou=groups
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								group_search_base_dns = ["ou=groups,dc=grafana,dc=org"]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Also change set `member_of = "cn"`  in the `[servers.attributes]`  section.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-12 02:58:30 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## LDAP to Grafana Org Role Sync
 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### Mappings
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								In `[[servers.group_mappings]]`  you can map an LDAP group to a Grafana organization
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								and role.  These will be synced every time the user logs in, with LDAP being
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								the authoritative source.  So, if you change a user's role in the Grafana Org.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Users page, this change will be reset the next time the user logs in. If you
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								change the LDAP groups of a user, the change will take effect the next
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								time the user logs in.
							 
						 
					
						
							
								
									
										
										
										
											2015-08-12 22:30:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								### Priority
 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-12 10:46:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								The first group mapping that an LDAP user is matched to will be used for the sync. If you have LDAP users that fit multiple mappings, the topmost mapping in the TOML config will be used.
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-26 23:21:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-15 20:48:39 +08:00