# 複数のLDAPサーバーの使用 (Linux RPM)

Active DirectoryまたはLDAPを複数のサーバーにまたがってデプロイしている場合、`/etc/guacamole`にある、`guacamole.properties`に似た設定ファイルである`ldap-servers.yml`を使用して、各LDAPサーバーを使用するようにGuacamoleを設定できます。複数のLDAPサーバーを使用するように設定されたGuacamoleインスタンスでユーザーを認証すると、認証が成功するまで、設定された各LDAPサーバーが順に試行されます。認証が失敗するのは、ユーザーが設定したクレデンシャルを承認する定義済みのLDAPサーバーが1台もない場合だけです。

`ldap-servers.yml`を使用すると、`guacamole.properties`内の値は引き続き有効ですが、代わりに`ldap-servers.yml`で定義されたLDAPサーバーのデフォルト値として機能します。

## `ldap-servers.yml`の概要 <a href="#id-.usingmultipleldapserversv2.x-overviewofldap-servers.yml" id="id-.usingmultipleldapserversv2.x-overviewofldap-servers.yml"></a>

`ldap-servers.yml`ファイルには、LDAPサーバーのYAMLリストが1つ含まれており、各サーバーの定義は、設定プロパティと値の単純なリストで構成されています。これらの設定プロパティは、「ldap-」プレフィックスが省略されていることを除いて、[`guacamole.properties`内で使用可能なLDAPプロパティ](https://docs.keeper.io/jp/keeper-connection-manager-jp/advanced-configuration/guacamole.properties/ldap-configuration-properties)と同じです。

たとえば、ユーザーの認証に使用できる2台のLDAPサーバーを定義する単純な`ldap-servers.yml`には、以下の行が含まれます。

```
- hostname: server1.example.net
  user-base-dn:OU=Users,DC=example,DC=net
  username-attribute: sAMAccountName
  search-bind-dn:CN=Guacamole,OU=Services,DC=example,DC=net
  search-bind-password:SomePassword!

- hostname: server2.example.net
  user-base-dn:OU=Users,DC=example,DC=net
  username-attribute: sAMAccountName
  search-bind-dn:CN=Guacamole,OU=Services,DC=example,DC=net
  search-bind-password:SomePassword!
```

ユーザーがログインしようとすると、Guacamoleは最初に定義されたLDAPサーバー（`server1.example.net`）に対してユーザーの認証を試みます。それが失敗した場合、Guacamoleは次のサーバー（`server2.example.net`）に進み、その後も同様です。定義済みの\_すべての\_LDAPサーバーに対して認証が失敗した場合にのみ、LDAPに対する認証は全体として失敗します。

## 共通のLDAPパラメータを簡略化 <a href="#id-.usingmultipleldapserversv2.x-abbreviatingcommonldapparameters" id="id-.usingmultipleldapserversv2.x-abbreviatingcommonldapparameters"></a>

上記の例で2台のサーバー間で異なるプロパティはホスト名だけであり、`ldap-servers.yml`を使用する場合、`guacamole.properties`がデフォルト値のソースとして機能するため、すべてのサーバーに共通する設定の詳細は、`guacamole.properties`内で指定する方がよいでしょう。

```
ldap-user-base-dn:OU=Users,DC=example,DC=net
ldap-username-attribute: sAMAccountName
ldap-search-bind-dn:CN=Guacamole,OU=Services,DC=example,DC=net
ldap-search-bind-password:SomePassword!
```

`ldap-servers.yml`の内容は、ホスト名だけに減らすことができます。

```
- hostname: server1.example.net
- hostname: server2.example.net
```

## 複数のLDAPサーバーにユーザーを分割 <a href="#id-.usingmultipleldapserversv2.x-splittingusersacrossmultipleldapservers" id="id-.usingmultipleldapserversv2.x-splittingusersacrossmultipleldapservers"></a>

`ldap-servers.yml`に記載されたLDAPサーバーを「`match-usernames`」オプションを使用して特定のユーザーのみに制限することもできます。このオプションは、単一の文字列と文字列の配列の両方を受け入れます。各文字列はPerl互換の正規表現です。また、正規表現にキャプチャグループが含まれている場合、**最初のキャプチャグループの内容が**[**ユーザーのGuacamole IDを示すユーザー名**](https://docs.keeper.io/jp/keeper-connection-manager-jp/authentication/authenticating-users-with-ldap/using-ldap-with-a-database)として使用されます。

たとえば、対応するドメインの異なる2台のLDAPサーバーを定義し、ユーザーがユーザー名を 「DOMAIN 1\username」 と入力するか 「DOMAIN 2\username」 と入力するかによって、それらのLDAPサーバーを使い分けるには、`ldap-servers.yml`を編集して以下のような行を追加してください。

```
- hostname: domain1.example.net
  user-base-dn:OU=Users,DC=domain1,DC=example,DC=net
  match-usernames:DOMAIN1\\(.*)

- hostname: domain2.example.net
  user-base-dn:OU=Users,DC=domain2,DC=example,DC=net
  match-usernames:DOMAIN2\\(.*)
```

上記で定義した各LDAPサーバーが使用されるのは、対応する正規表現がユーザーが指定したユーザー名と一致する場合のみです。上記の例の各正規表現は、「DOMAIN\username」形式のユーザー名部分を囲むキャプチャグループを定義しているため、設定されたユーザー名のその部分を使用して、ユーザーのIDを特定します。ユーザーが「DOMAIN 1\myusername」として正常に認証された場合、以下のように使用されます。

* キャプチャされた部分（「myusername」）は、[Guacamoleのデータベース内のユーザーの該当するアカウントを識別する](https://docs.keeper.io/jp/keeper-connection-manager-jp/authentication/authenticating-users-with-ldap/using-ldap-with-a-database)ために使用されます。
* キャプチャされた部分（「myusername」）は、[ユーザーを完全修飾LDAP DNにマッピングする](/keeper-connection-manager/jp/authentication/authenticating-users-with-ldap.md)ときに使用されます。

各LDAPサーバーで受け入れが必要なユーザー名形式が複数ある場合は、複数の正規表現を指定できます。たとえば、「MYDOMAIN\myusername」とUPNスタイルの「<myusername@mydomain.example.net>」形式の両方に合致させるには、以下のように指定してください。

```
- hostname: domain1.example.net
  user-base-dn:OU=Users,DC=domain1,DC=example,DC=net
  match-usernames:
    - DOMAIN1\\(.*)
    - (.*)@domain1\.example\.net

- hostname: domain2.example.net
  user-base-dn:OU=Users,DC=domain2,DC=example,DC=net
  match-usernames:
    - DOMAIN2\\(.*)
    - (.*)@domain2\.example\.net
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/keeper-connection-manager/jp/authentication/authenticating-users-with-ldap/noldapsbno-linux-rpm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
