Configuring an LDAP provider in DataLens On-premises

To configure an LDAP provider, you need to create a configuration for connection to an LDAP server and user attribute mapping.

Main configuration parameters

{
    slug: 'openldap',                  // Unique provider ID
    title: 'OpenLDAP',                 // Displayed provider name
    type: 'ldap',                      // Provider type (use 'ldap')
    defaultRole: 'datalens.visitor',   // Default role for new users
    config: {
        // LDAP server connection parameters
        url: 'ldap://localhost:8389',  // LDAP server URL
        bindDN: 'cn=admin,dc=example,dc=org',  // DN for the administrative connection
        bindCredentials: 'admin',      // Administrative connection password
        bindProperty: 'dn',            // Administrative connection attribute

        // User search parameters
        searchBase: 'ou=users,dc=example,dc=org',  // User search base
        searchFilter: '(uid={{username}})',        // User search filter
        searchScope: 'sub',                        // Search area: 'base', 'one', or 'sub'

        // Group search parameters (optional)
        groupSearchBase: 'ou=groups,dc=example,dc=org',  // Group search base
        groupSearchFilter: '(&(objectClass=groupOfNames)(member={{dn}}))',  // Group search filter
        groupDnProperty: 'dn',                           // Group DN attribute
        groupSearchScope: 'sub',                         // Group search area

        // User attribute mapping (optional)
        userAttributes: {
            userId: 'uid',       // User ID attribute ('uid' by default)
            login: 'uid',        // User login attribute ('uid' by default)
            email: 'mail',       // User email address attribute ('mail' by default)
            firstName: 'givenName', // User first name attribute ('givenName' by default)
            lastName: 'sn',      // User last name attribute ('sn' by default)
        },

        // Group attribute mapping (optional)
        groupAttributes: {
            groupId: 'dn',       // Group ID attribute ('dn' by default)
            title: 'cn',         // Group name attribute ('cn' by default)
        },

        // Mapping of DataLens roles for LDAP groups (optional)
        roleToGroupId: {
            'datalens.admin': 'cn=datalensadmin,ou=groups,dc=example,dc=org',
            'datalens.creator': 'cn=datalenscreator,ou=groups,dc=example,dc=org',
            'datalens.visitor': 'cn=datalensvisitor,ou=groups,dc=example,dc=org',
        },

        // Additional settings
        syncUserRoles: true,     // Synchronizing user roles at each log-in (true by default)
        syncUserGroups: true,    // Synchronizing user groups at each log-in (true by default)
    }
}

Parameter descriptions

Basic parameters

  • slug: Unique provider ID used in URLs and internal IDs.
  • title: Provider name displayed in the interface.
  • type: Provider type; for LDAP, use ldap.
  • defaultRole: Role assigned to the user if unable to define a role according to LDAP groups.

LDAP server connection parameters

  • url: LDAP server URL, e.g., ldap://localhost:389 or ldaps://ldap.example.com:636.
  • bindDN: Unique Distinguished Name (DN) for the administrative LDAP server connection.
  • bindCredentials: Administrative connection password.
  • bindProperty: User’s LDAP object attribute used for password checking as a bind property, e.g., name, email. The default value is dn.

User search parameters

  • searchBase: User search base in LDAP, e.g., ou=users,dc=example,dc=org.

  • searchFilter: User search filter. Use the {{ username }} template to substitute the login entered by the user.

  • searchScope: Search scope:

    • base: Search within the specified base only.
    • one: Search within the base and one level below.
    • sub: Recursive search in all subtrees.

Group search parameters (optional)

  • groupSearchBase: Group search base in LDAP, e.g., ou=groups,dc=example,dc=org.
  • groupSearchFilter: Group search filter. Use {{ dn }} to substitute the DN of the found user.
  • groupDnProperty: User object attribute injected into {{ dn }} inside groupSearchFilter (dn by default).
  • groupSearchScope: Group search area (similar to searchScope).

User attribute mapping

Allows you to set up the mapping between the LDAP user attributes and the user’s fields in the system:

  • userId: User ID attribute (uid by default).
  • login: User login attribute (uid by default).
  • email: User email address attribute (mail by default).
  • firstName: User first name attribute (givenName by default).
  • lastName: User last name attribute (sn by default).

Group attribute mapping

Allows you to set up the mapping between the LDAP groups' attributes and the groups' fields in the system:

  • groupId: Group ID attribute (dn by default).
  • title: Group name attribute (cn by default).

Mapping of LDAP group roles

Allows you to set up the mapping between DataLens roles and LDAP groups.

Algorithm of synchronization between groups and roles:

  1. A search for the user's LDAP groups is performed.
  2. For each group, a search is performed in roleToGroupId based on the group ID (an attribute from groupAttributes). Once a group is found in roleToGroupId, a relevant role will be assigned to the user.

Here is an example:

roleToGroupId: {
    'datalens.admin': 'cn=datalensadmin,ou=groups,dc=example,dc=org',
    'datalens.creator': 'cn=datalenscreator,ou=groups,dc=example,dc=org',
    'datalens.visitor': 'cn=datalensvisitor,ou=groups,dc=example,dc=org',
}

Where:

  • 'cn=datalensadmin,ou=groups,dc=example,dc=org', 'cn=datalenscreator,ou=groups,dc=example,dc=org', and 'cn=datalensvisitor,ou=groups,dc=example,dc=org': Group IDs and search base (ou=groups,dc=example,dc=org) in LDAP.
  • 'datalens.admin', 'datalens.creator', and 'datalens.visitor': DataLens roles.

If the user is a member of the cn=datalensadmin group, the datalens.admin role will be assigned.

Additional settings

  • syncUserRoles: When set to true (default value), user roles will be synchronized at each log-in.
  • syncUserGroups: When set to true (default value), user groups will be synchronized at each log-in.

Aspects of role and group synchronization

User roles and groups are synchronized the moment the user logs in to the system. If the user is a member of a group specified in the configuration, the relevant role will be assigned to the user, and the group will appear in DataLens and will be available in the access permissions. If the user is not a group member, the default role will be assigned. If there are more than 100 groups, synchronization will be skipped. If you need to synchronize more groups, set up regular group synchronization using a synchronization script.