You can configure X-Pack security to communicate with Active Directory to authenticate
users. To integrate with Active Directory, you configure an
realm and map Active Directory users and groups to X-Pack security roles in the
role mapping file.
To protect passwords, communications between Elasticsearch and the Active Directory server should be encrypted using SSL/TLS. Clients and nodes that connect via SSL/TLS to the Active Directory server need to have the Active Directory server’s certificate or the server’s root CA certificate installed in their keystore or truststore. For more information about installing certificates, see Setting up SSL Between Elasticsearch and Active Directory.
X-Pack security uses LDAP to communicate with Active Directory, so
realms are similar to
ldap realms. Like LDAP directories,
Active Directory stores users and groups hierarchically. The directory’s
hierarchy is built from containers such as the organizational unit (
o), and domain controller (
The path to an entry is a Distinguished Name (DN) that uniquely identifies a
user or group. User and group names typically have attributes such as a
common name (
cn) or unique ID (
uid). A DN is specified as a string, for
"cn=admin,dc=example,dc=com" (white spaces are ignored).
X-Pack security only supports Active Directory security groups. You cannot map distribution groups to roles.
When you use Active Directory for authentication, the username entered by
the user is expected to match the
not the common name.
To configure an
Add a realm configuration of type
xpack.security.authc.realmsnamespace. At a minimum, you must set the realm
active_directoryand specify the Active Directory
domain_name. To use SSL/TLS for secured communication with the Active Directory server, you must also set the
urlattribute and specify the
ldapsprotocol and secure port number. If you are configuring multiple realms, you should also explicitly set the
orderattribute to control the order in which the realms are consulted during authentication. See Active Directory Realm Settings for all of the options you can set for an
Binding to Active Directory fails if the domain name is not mapped in DNS. If DNS is not being provided by a Windows DNS server, add a mapping for the domain in the local
For example, the following realm configuration configures X-Pack security to connect to
ldaps://example.com:636to authenticate users through Active Directory.
The realm order controls the order in which the configured realms are checked when authenticating a user.
If you don’t specify the URL, it defaults to
When this option is enabled, Active Directory groups are automatically mapped to roles of the same name.
When you configure realms in
elasticsearch.yml, only the realms you specify are used for authentication. If you also want to use the
filerealms, you must include them in the realm chain.
- Restart Elasticsearch.
When authenticating users across multiple domains in a forest, there are a few minor
differences in the configuration and the way that users will authenticate. The
setting should be set to the forest root domain name. The
url setting also needs to
be set as you will need to authenticate against the Global Catalog, which uses a different
port and may not be running on every Domain Controller.
For example, the following realm configuration configures X-Pack security to connect to specific Domain Controllers on the Global Catalog port with the domain name set to the forest root.
A load balancing setting is provided to indicate the desired behavior when choosing the server to connect to.
In this configuration, users will need to use either their full User Principal
Name (UPN) or their Down-Level Logon Name. A UPN is typically a concatenation of
the username with
@<DOMAIN_NAME such as
firstname.lastname@example.org. The Down-Level
Logon Name is the NetBIOS domain name, followed by a
\ and the username, such as
AD\johndoe. Use of Down-Level Logon Name requires a connection to the regular LDAP
ports (389 or 636) in order to query the configuration container to retrieve the
domain name from the NetBIOS name.
load_balance.type setting can be used at the realm level to configure how
X-Pack security should interact with multiple Active Directory servers. Two modes of
operation are supported: failover and load balancing
Table 9. Load Balancing and Failover Types
The URLs specified are used in the order that they are specified. The first server that can be connected to will be used for all subsequent connections. If a connection to that server fails then the next server that a connection can be established to will be used for subsequent connections.
In this mode of operation, only a single URL may be specified.
This URL must contain a DNS name. The system will be queried
for all IP addresses that correspond to this DNS name.
Connections to the Active Directory server will always be
tried in the order in which they were retrieved. This differs
Connections will continuously iterate through the list of provided URLs. If a server is unavailable, iterating through the list of URLs will continue until a successful connection is made.
In this mode of operation, only a single URL may be specified. This URL must contain a DNS name. The system will be queried for all IP addresses that correspond to this DNS name. Connections will continuously iterate through the list of addresses. If a server is unavailable, iterating through the list of URLs will continue until a successful connection is made.
Indicates the realm type. Must be set to
Indicates the priority of this realm within the realm chain.
Realms with a lower order are consulted first. Although not
required, we recommend explicitly setting this value when
you configure multiple realms. Defaults to
Indicates whether this realm is enabled or disabled. Enables
you to disable a realm without removing its configuration.
Specifies the domain name of the Active Directory. X-Pack security
uses the domain name to derive the LDAP URL and
Specifies an LDAP URL of the form
The behavior to use when there are multiple LDAP URLs defined. For supported values see Load Balancing and Failover.
Specifies the context to search for the user. Defaults to the root of the Active Directory domain.
Specifies whether the user search should be
Specifies a filter to use to lookup a user given a username.
The default filter looks up
Specifies the context to search for groups in which the user has membership. Defaults to the root of the Active Directory domain.
Specifies whether the group search should be
Specifies whether the names of any unmapped Active Directory
groups should be used as role names and assigned to the user.
Specifies the path and file name of the
YAML role mapping configuration file.
Specifies whether X-Pack security should follow referrals returned
by the Active Directory server. Referrals are URLs returned by
the server that are to be used to continue the LDAP operation
Specifies the path to the PEM encoded private key to use if the Active Directory
server requires client authentication.
Specifies the passphrase to decrypt the PEM encoded private key if it is encrypted.
Specifies the path to the PEM encoded certificate (or certificate chain) that goes with the key if the Active Directory server requires client authentication.
Specifies the paths to the PEM encoded certificate authority certificates that
should be trusted.
The path to the Java Keystore file that contains a private key and certificate.
The password to the keystore.
The password for the key in the keystore. Defaults to the keystore password.
The path to the Java Keystore file that contains the certificates to trust.
The password to the truststore.
Specifies the type of verification to be performed when
connecting to an Active Directory server using
Specifies the supported protocols for TLS/SSL.
Specifies the cipher suites that should be supported when communicating with the Active Directory server.
Specifies the time-to-live for cached user entries. A user’s
credentials are cached for this period of time. Specify the
time period using the standard Elasticsearch
Specifies the maximum number of user entries that can be stored in the cache at one time. Defaults to 100,000.
Specifies the hashing algorithm that is used for the cached user credentials. See Cache hash algorithms for the possible values. (Expert Setting).
An integral part of a realm authentication process is to resolve the roles associated with the authenticated user. Roles define the privileges a user has in the cluster.
Since with the
active_directory realm the users are managed externally in the
Active Directory server, the expectation is that their roles are managed there
as well. In fact, Active Directory supports the notion of groups, which often
represent user roles for different systems in the organization.
active_directory realm enables you to map Active Directory users and groups
to roles in the role mapping file stored on each node. You specify users and
groups using their distinguished names (DNs). For example, the following mapping
configuration maps the Active Directory
admins group to both the
user roles, maps the
users group to the
user role and maps the
user to the
The name of the role.
The Active Directory distinguished name (DN) of the
The Active Directory distinguished name (DN) of the
The Active Directory distinguished name (DN) of the user
For more information, see Mapping Users and Groups to Roles.
To protect the user credentials that are sent for authentication, it’s highly recommended to encrypt communications between Elasticsearch and your Active Directory server. Connecting via SSL/TLS ensures that the identity of the Active Directory server is authenticated before X-Pack security transmits the user credentials, and the usernames and passwords are encrypted in transit.
To encrypt communications between Elasticsearch and Active Directory:
Configure each node to trust certificates signed by the CA that signed your Active Directory server certificates. The following example demonstrates how to trust a CA certificate,
cacert.pem, located within the X-Pack configuration directory:
xpack: security: authc: realms: active_directory: type: active_directory order: 0 domain_name: ad.example.com url: ldaps://ad.example.com:636 ssl: certificate_authorities: [ "CONFIG_DIR/x-pack/cacert.pem" ]
The CA cert must be a PEM encoded certificate.
urlattribute in the realm configuration to specify the LDAPS protocol and the secure port number. For example,
- Restart Elasticsearch.
By default, when you configure X-Pack security to connect to Active Directory
using SSL/TLS, X-Pack security attempts to verify the hostname or IP address
specified with the
url attribute in the realm configuration with the
values in the certificate. If the values in the certificate and realm
configuration do not match, X-Pack security does not allow a connection to the
Active Directory server. This is done to protect against man-in-the-middle
attacks. If necessary, you can disable this behavior by setting the
ssl.verification_mode property to