Mapping Users and Groups to Roles

If you authenticate users with the native realm, you assign roles to users through the User Management APIs. If you use the file realm, you assign roles with the esusers command-line tool.

For other types of realms, you configure role mappings for users and groups in a YAML file and copy it to each node in the cluster. Tools like Puppet or Chef can help with this.

By default, role mappings are stored in CONF_DIR/shield/role_mapping.yml, where CONF_DIR is ES_HOME/config (zip/tar installations) or /etc/elasticsearch (package installations). To specify a different location, you configure the role_mapping settings in elasticsearch.yml. The role_mapping settings enable you to use a different set of mappings for each realm type:

The location of the role mappings for LDAP realms.
The location of the role mappings for Active Directory realms.
The location of the role mappings for PKI realms.

For Shield to read the mapping file, it must be stored in the Elasticsearch CONF_DIR.

Within the role mapping file, Shield roles are keys and groups and users are values. The mappings can have a many-to-many relationship. When you map roles to groups, the roles of a user in that group are the combination of the roles assigned to that group and the roles assigned to that user.

The available roles are defined in the roles file. To specify users and groups in the role mappings, you use their Distinguished Names (DNs). A DN is a string that uniquely identifies the user or group, for example "cn=John Doe,cn=contractors,dc=example,dc=com".


Shield only supports Active Directory security groups. You cannot map distribution groups to roles.

For example, the following snippet maps the admins group to the monitoring role and maps John Doe, the users group, and the admins group to the user role.

  - "cn=admins,dc=example,dc=com" 
  - "cn=John Doe,cn=contractors,dc=example,dc=com" 
  - "cn=users,dc=example,dc=com"
  - "cn=admins,dc=example,dc=com"

The name of a Shield role defined in the roles file.

The distinguished name of an LDAP group or an Active Directory security group.

The distinguished name of an LDAP or Active Directory user. [1.1.0] Added in 1.1.0.

PKI realms only support mapping users to roles, as there is no notion of a group in PKI. For example:

  - "cn=Admin,ou=example,o=com"
  - "cn=John Doe,ou=example,o=com"