> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 인증 및 역할 매핑에 LDAP를 사용하도록 ClickHouse 구성

> 인증 및 역할 매핑에 LDAP를 사용하도록 ClickHouse를 구성하는 방법을 설명합니다

export const CloudNotSupportedBadge = () => {
  return <div className="cloudNotSupportedBadge">
            <div className="cloudNotSupportedIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path strokeWidth="1.5" d="M6.33366 12.6666L12.3739 12.6667C13.6593 12.6667 14.7073 11.6187 14.7073 10.3334C14.7073 9.04804 13.6593 8.00003 12.3739 8.00003C12.3739 8.00003 12.3337 7.66659 12.0003 7.33325M10.667 5.33322C8.00033 2.33325 4.45395 4.78537 4.14195 6.68203C2.55728 6.7627 1.29395 8.06203 1.29395 9.6667C1.29395 11.3234 2.66699 12.6666 4.00033 12.6666" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.5" d="M2.66699 14L12.0003 4.66663" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
            </svg>

        </div>
            ClickHouse Cloud에서 지원되지 않음
        </div>;
};

<CloudNotSupportedBadge />

<Note>
  이 페이지는 [ClickHouse Cloud](https://clickhouse.com/cloud)에는 적용되지 않습니다. 여기에서 설명하는 기능은 ClickHouse Cloud 서비스에서 지원되지 않습니다.
  자세한 내용은 ClickHouse의 [Cloud Compatibility](/docs/ko/products/cloud/guides/cloud-compatibility) 가이드를 참조하십시오.
</Note>

ClickHouse는 LDAP를 사용해 ClickHouse 데이터베이스 사용자를 인증하도록 구성할 수 있습니다. 이 가이드에서는 공개적으로 접근 가능한 디렉터리를 대상으로 인증하는 LDAP 시스템과 ClickHouse를 통합하는 간단한 예시를 제공합니다.

<Steps>
  <Step title="ClickHouse에서 LDAP 연결 설정 구성" id="1-configure-ldap-connection-settings-in-clickhouse">
    1. 이 공개 LDAP 서버에 대한 연결을 테스트합니다:

       ```bash theme={null}
       $ ldapsearch -x -b dc=example,dc=com -H ldap://ldap.forumsys.com
       ```

       응답은 다음과 비슷합니다:

       ```response theme={null}
       # 확장 LDIF
       #
       # LDAPv3
       # base <dc=example,dc=com>, scope subtree
       # filter: (objectclass=*)
       # 요청 항목: ALL
       #

       # example.com
       dn: dc=example,dc=com
       objectClass: top
       objectClass: dcObject
       objectClass: organization
       o: example.com
       dc: example
       ...
       ```

    2. `config.xml` 파일을 편집하고 LDAP를 구성하려면 다음 내용을 추가합니다:
       ```xml theme={null}
       <ldap_servers>
           <test_ldap_server>
           <host>ldap.forumsys.com</host>
           <port>389</port>
           <bind_dn>uid={user_name},dc=example,dc=com</bind_dn>
           <enable_tls>no</enable_tls>
           <tls_require_cert>never</tls_require_cert>
           </test_ldap_server>
       </ldap_servers>
       ```

    <Note>
      `<test_ldap_server>` 태그는 특정 LDAP 서버를 식별하기 위한 임의의 레이블입니다.
    </Note>

    위에서 사용한 기본 설정은 다음과 같습니다:

    | Parameter          | Description         | Example                             |
    | ------------------ | ------------------- | ----------------------------------- |
    | host               | LDAP 서버의 호스트명 또는 IP | ldap.forumsys.com                   |
    | port               | LDAP 서버의 디렉터리 포트    | 389                                 |
    | bind\_dn           | 사용자에 대한 템플릿 경로      | `uid={user_name},dc=example,dc=com` |
    | enable\_tls        | 보안 LDAP 사용 여부       | no                                  |
    | tls\_require\_cert | 연결 시 인증서가 필요한지 여부   | never                               |

    <Note>
      이 예시에서는 공개 서버가 389를 사용하고 보안 포트를 사용하지 않으므로, 시연 목적으로 TLS를 비활성화합니다.
    </Note>

    <Note>
      LDAP 설정에 대한 자세한 내용은 [LDAP 문서 페이지](/docs/ko/concepts/features/security/external-authenticators/ldap)를 참조하십시오.
    </Note>

    3. 사용자 역할 매핑을 구성하려면 `<user_directories>` 섹션에 `<ldap>` 섹션을 추가합니다. 이 섹션은 사용자가 인증될 때와 사용자에게 어떤 역할이 부여되는지를 정의합니다. 이 기본 예시에서는 LDAP로 인증하는 모든 사용자에게 `scientists_role`이 부여되며, 이 역할은 이후 단계에서 ClickHouse에 정의됩니다. 섹션은 다음과 비슷해야 합니다:

       ```xml theme={null}
       <user_directories>
           <users_xml>
               <path>users.xml</path>
           </users_xml>
           <local_directory>
               <path>/var/lib/clickhouse/access/</path>
           </local_directory>
           <ldap>
                 <server>test_ldap_server</server>
                 <roles>
                    <scientists_role />
                 </roles>
                 <role_mapping>
                    <base_dn>dc=example,dc=com</base_dn>
                    <search_filter>(&amp;(objectClass=groupOfUniqueNames)(uniqueMember={bind_dn}))</search_filter>
                    <attribute>cn</attribute>
                 </role_mapping>
           </ldap>
       </user_directories>
       ```

       위에서 사용한 기본 설정은 다음과 같습니다:

       | Parameter      | Description                             | Example                                                       |
       | -------------- | --------------------------------------- | ------------------------------------------------------------- |
       | server         | 앞의 ldap\_servers 섹션에서 정의한 레이블           | test\_ldap\_server                                            |
       | roles          | 사용자가 매핑될 ClickHouse에서 정의된 역할 이름         | scientists\_role                                              |
       | base\_dn       | 사용자와 연결된 그룹 검색을 시작할 기본 경로               | dc=example,dc=com                                             |
       | search\_filter | 사용자 매핑에 사용할 그룹을 식별하는 LDAP search filter | `(&(objectClass=groupOfUniqueNames)(uniqueMember={bind_dn}))` |
       | attribute      | 값을 반환할 속성 이름                            | cn                                                            |

    4. 설정을 적용하려면 ClickHouse 서버를 다시 시작합니다.
  </Step>

  <Step title="ClickHouse 데이터베이스 역할 및 권한 구성" id="2-configure-clickhouse-database-roles-and-permissions">
    <Note>
      이 섹션의 절차는 ClickHouse에서 SQL 액세스 제어 및 계정 관리가 활성화되어 있다고 가정합니다. 활성화하려면 [SQL Users and Roles 가이드](/docs/ko/concepts/features/security/access-rights)를 참조하십시오.
    </Note>

    1. `config.xml` 파일의 역할 매핑 섹션에서 사용한 것과 동일한 이름으로 ClickHouse에서 역할을 생성합니다.
       ```sql theme={null}
       CREATE ROLE scientists_role;
       ```

    2. 역할에 필요한 권한을 부여합니다. 다음 문은 LDAP를 통해 인증할 수 있는 모든 사용자에게 관리자 권한을 부여합니다.
       ```sql theme={null}
       GRANT ALL ON *.* TO scientists_role;
       ```
  </Step>

  <Step title="LDAP 구성을 테스트합니다" id="3-test-the-ldap-configuration">
    1. ClickHouse client로 로그인합니다
       ```bash theme={null}
       $ clickhouse-client --user einstein --password password
       ClickHouse client version 22.2.2.1.
       Connecting to localhost:9000 as user einstein.
       Connected to ClickHouse server version 22.2.2 revision 54455.

       chnode1 :)
       ```

    <Note>
      1단계에서 `ldapsearch` 명령을 사용해 디렉터리에서 사용할 수 있는 모든 사용자를 확인하십시오. 모든 사용자의 비밀번호는 `password`입니다.
    </Note>

    2. 사용자가 `scientists_role` 역할에 올바르게 매핑되었고 관리자 권한을 가지고 있는지 테스트합니다

       ```sql theme={null}
       SHOW DATABASES
       ```

       ```response theme={null}
       Query id: 93b785ff-1482-4eda-95b0-b2d68b2c5e0f

       ┌─name───────────────┐
       │ INFORMATION_SCHEMA │
       │ db1_mysql          │
       │ db2                │
       │ db3                │
       │ db4_mysql          │
       │ db5_merge          │
       │ default            │
       │ information_schema │
       │ system             │
       └────────────────────┘

       9 rows in set. Elapsed: 0.004 sec.
       ```
  </Step>
</Steps>

<div id="summary">
  ## 요약
</div>

이 문서에서는 ClickHouse가 LDAP 서버에 인증하도록 구성하고 역할(Role)에 매핑하는 기본 사항을 설명했습니다. 또한 ClickHouse에서 개별 사용자를 구성하되 자동 역할 매핑을 설정하지 않고도 해당 사용자가 LDAP로 인증되도록 할 수 있는 옵션도 있습니다. LDAP 모듈은 Active Directory에 연결하는 데에도 사용할 수 있습니다.
