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_3Rwith 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:
- 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:
- In ClickHouse
config.xml, add theldap_serversconfiguration to each ClickHouse node.
Refer to documentation for full set of options:
https://clickhouse.com/docs/operations/external-authenticators/ldap#ldap-server-definition
- 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.
:::
- Create example databases.
- Create example tables.
- Insert sample data.
- Create ClickHouse Roles.
- Grant the privileges to the roles.
- Test access for restricted db1 user. For example:
- Test access for the user that has access to both databases, db1 and db2. For example:
- Test access for the Admin user. For example: