Skip to main content

Example

This example shows how AD users that belong to different AD security groups can be given role access in ClickHouse. It also shows how a user may be added to multiple AD user groups so they can have access provided by multiple roles. In this environment, we have the following:
  • A Windows Active Directory domain: marsnet2.local
  • A ClickHouse Cluster, cluster_1S_3R with 3 nodes on a cluster configuration of 1 shard, 3 replicas
  • 3 AD users
  • 3 AD security groups
  • Example AD Environment and UO structure:
  • Example AD Security Group Configuration:
  • Example AD User Configuration:
  1. In Windows AD Users and Groups, add each user to their respective group(s), they will be mapped to the ClickHouse roles (example in the next step).
  • Example user group membership:
  1. In ClickHouse config.xml, add the ldap_servers configuration to each ClickHouse node.
Refer to documentation for full set of options: https://clickhouse.com/docs/operations/external-authenticators/ldap#ldap-server-definition
  1. In ClickHouse config.xml, add the <user_directories> configuration with <ldap> entries to each ClickHouse node.
Refer to documentation for full set of options: https://clickhouse.com/docs/operations/external-authenticators/ldap#ldap-external-user-directory note::: Since the AD security groups were prefixed in the example - i.e. clickhouse_ad_db1_users- when the system retrieves them, the prefix will be removed and the system will look for a ClickHouse role called ad_db1_users to map to clickhouse_ad_db1_users. :::
  1. Create example databases.
  1. Create example tables.
  1. Insert sample data.
  1. Create ClickHouse Roles.
  1. Grant the privileges to the roles.
  1. Test access for restricted db1 user. For example:
  1. Test access for the user that has access to both databases, db1 and db2. For example:
  1. Test access for the Admin user. For example:
Last modified on June 19, 2026