---
schema_version: "1"
id: 01449ac1f64640094aba42a4881bb6c12b6405dabd10a3c1a021060b7e935067
title: "基本認証: LDAP ポリシー"
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/mule-gateway/policies-included-basic-auth-ldap.md
canonical_url: https://docs.mulesoft.com/jp/mule-gateway/policies-included-basic-auth-ldap
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 07deff0376491201468ed9d5f5208b3d0cf45242db333f7b5c26b07e4fca67b3
description: MuleSoft Documentation Site
latest: true
---
# 基本認証: LDAP ポリシー

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-right valign-top"><p class="tableblock"><strong>ポリシー名</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">基本認証: LDAP</p></td>
</tr>
<tr>
<td class="tableblock halign-right valign-top"><p class="tableblock"><strong>概要</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">LDAP で定義されたユーザー-パスワードを使用して基本認証メカニズムに基づいてアクセスを許可する</p></td>
</tr>
<tr>
<td class="tableblock halign-right valign-top"><p class="tableblock"><strong>カテゴリ</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">セキュリティ</p></td>
</tr>
<tr>
<td class="tableblock halign-right valign-top"><p class="tableblock"><strong>使用可能な最小 Mule バージョン</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">v4.0.0</p></td>
</tr>
<tr>
<td class="tableblock halign-right valign-middle"><p class="tableblock"><strong>返される状況コード</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">401 - 未承認または無効なクライアントアプリケーションのログイン情報</p></td>
</tr>
</tbody>
</table>

## [](#概要)概要

Lightweight Directory Access Protocol (LDAP) 認証ポリシーは、LDAP 認証メカニズムを使用して API へのアクセスを制限する方法を指定します。このポリシーは、Flex および Mule 4 以降で使用できます。

エラーに遭遇すると、基本認証 - LDAP ポリシーは ​`WWW-Authenticate: Basic realm="mule-realm"`​ の形式で「WWW-Authenticate」 HTTP ヘッダー項目を返します。

LDAP は上下反転した木であり、それぞれの葉にユーザー名-パスワードのペアおよび関連付けられたメタデータがあります。各レベルは木の枝のように分かれています。LDAP の詳細については、 [「LDAP^ について」](https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol)​を参照してください。

## [](#ポリシーのパラメーターの設定)ポリシーのパラメーターの設定

### [](#mule-ゲートウェイ)Mule ゲートウェイ

UI から基本認証 - LDAP ポリシーを API に適用する場合は、LDAP または Active Directory に接続するための以下のパラメーターを設定できます。

<table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">パラメーター</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Server URL (LDAP サーバー URL)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>ポート番号を含む、LDAP または LDAPS サーバーの URL。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP User DN (LDAP ユーザー DN)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP のユーザーをトラバースおよびリストするためのアクセス権を持つユーザーまたはユーザーグループの名前。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP User Password (LDAP ユーザーパスワード)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>ユーザーまたはユーザーグループのパスワード。パスワードはセキュアな値でなければなりません。これは、指定すると表示または再取得できなくなる値です。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Search Base (LDAP 検索ベース)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>ディレクトリツリー内の検索の開始点。</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Search Filter (LDAP 検索条件)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>Active Directory または OpenLDAP モデルの検索条件。例を参照してください。</p>
</div></div></td>
</tr>
</tbody>
</table>

LDAP または Active Directory に正常に接続するには、すべてのパラメーターが必要です。

## [](#active-directory-の設定例)Active Directory の設定例

以下の値を設定することで、Active Directory の LDAP 認証を設定できます。

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">リテラル文字列値の例</th>
<th class="tableblock halign-left valign-top">セキュアプロパティプレースホルダーの例</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Server URL (LDAP サーバー URL)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>ldap://174.19.33.17:389/</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.server.url}</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Secure Server URL (SSL) (LDAP セキュアサーバー URL (SSL))</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>ldaps://my-company-ldap.cloudhub.io:1010/</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.server.url}</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Server User DN (LDAP サーバーユーザー DN)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>CN=Administrator,CN=Users,DC=my-company,DC=com</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.user.dn}</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP User Password (LDAP ユーザーパスワード)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>somePassword</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.password}</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Search Base (LDAP 検索ベース)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>CN=Users,DC=my-company,DC=com</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.search.base}</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Search Filter (LDAP 検索条件)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>(sAMAccountName={0})</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.search.filter}</p>
</div></div></td>
</tr>
</tbody>
</table>

例の検索条件文字列は Active Directory アプリケーションに固有です。

## [](#openldap-の設定例)OpenLDAP の設定例

以下の値を設定することで、OpenLDAP の LDAP 認証を設定できます。

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">リテラル文字列値の例</th>
<th class="tableblock halign-left valign-top">セキュアプロパティプレースホルダーの例</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Server URL (LDAP サーバー URL)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>ldap://174.19.33.17:389/</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.server.url}</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Secure Server URL (SSL) (LDAP セキュアサーバー URL (SSL))</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>ldaps://my-company-ldap.cloudhub.io:1010/</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.server.url}</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Server User DN (LDAP サーバーユーザー DN)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>cn=Manager,dc=my-company,dc=com</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.user.dn}</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP User Password (LDAP ユーザーパスワード)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>somePassword</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.password}</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Search Base (LDAP 検索ベース)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>ou=people,dc=my-company,dc=com</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.search.base}</p>
</div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>LDAP Search Filter (LDAP 検索条件)</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>(uid={0})</p>
</div></div></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p>${ldap.search.filter}</p>
</div></div></td>
</tr>
</tbody>
</table>

例の検索条件文字列は OpenLDAP アプリケーションに固有です。

## [](#ポリシーのしくみ)ポリシーのしくみ

基本認証 - LDAP ポリシーは、保護されているリソースに対する要求を捕捉して、​`Authorization`​ HTTP ヘッダーを確認します。

そして、Base64 でエンコードされているユーザー名とパスワードを抽出して、設定されている LDAP インスタンスに対して、提供されている LDAP コンテキストにおいてユーザーのログイン情報が正しいかどうかを判断するように要求します。

ログイン情報に対する基本認証: LDAP ポリシーは、以下の方法を使用して設定できます。

- 指定されているレベルでユーザー名とパスワードのペアを検索する。
- 指定されているレベルとその下位レベルでユーザー名とパスワードのペアを検索する。ただし、この検索オプションは包括的であるため、パフォーマンスが低下することがあります。

### [](#検索スコープ)検索スコープ

検索スコープオプションは、使用しているポリシーバージョンによって異なります。検索スコープオプションは、LDAP 1.0.0 では 1 レベル、LDAP 1.1.0 では 2 レベル (サブツリー) となります。

`one level`​ または ​`subtree`​ の検索スコープは、​`LDAP Search in subtree`​ オプションを使用して選択します。

`LDAP search base`​ は、ディレクトリ内の検索の開始点です。

### [](#1-レベル検索スコープ)1 レベル検索スコープ

このオプションを使用すると、検索条件は ​`LDAP search base`​ 直下のオブジェクトのみに影響しますが、​`LDAP search base`​ 自身は含まれません。

次の例では、第 1 レベルに 4 つのエントリ (2 つのユーザーと 2 つのグループ) があります。検索にはこれらのエントリのみが含まれます。

![階層チャートに組織構造およびユーザー ID が表示されます](/mulesoft/current/ja-jp/mule-gateway/_images/search-scope.png)

検索条件を ​`(uid={0})`​ に設定した場合、​`Jane`​ と ​`Paul`​ のみが見つかります。グループエントリは考慮されません。

#### [](#サブツリー検索スコープ)サブツリー検索スコープ

このオプションを使用すると、基本認証 - LDAP ポリシーは ​`LDAP search base`​ の下のサブツリーも調べ、​`LDAP search base`​ レベルも含めます。ただし、この動作によりパフォーマンスが影響を受けます。

上の例では、分析される領域には組織全体が含まれます。組織のすべてのレベルでグループエントリとユーザーエントリが考慮されます。

![階層チャートに会社の組織構造が表示されます](/mulesoft/current/ja-jp/mule-gateway/_images/search-scope2.png)

## [](#基本認証ポリシーが適用された-api-への要求の作成)基本認証ポリシーが適用された API への要求の作成

基本認証 - LDAP ポリシーを API に適用した後は、その API への要求には次のヘッダーを含める必要があります。

Authorization: Basic <username:password>

`username:password`​ の値は Base64 でエンコードされた文字列である必要があります。たとえば、Mac OS X や Linux システムでは、ユーザー名とパスワードの要件は次のように実装されます。

`echo -n '<Client Id>:<Client Secret>' | base64`

Mule Runtime Engine (Mule) はヘッダーのログイン情報を分割し、要求を LDAP サーバーに検索条件と共に送信します。

LDAP は ​`username`​ と検索条件から登録済みユーザーを見つけた後に、ログイン情報を検証します。有効な結果が Mule に返されます。

![LDAP サーバーを介したクライアント認証のメッセージフローを示すシーケンス図](/mulesoft/current/ja-jp/mule-gateway/_images/ldap-verification.png)

無効な要求の例を下図に示します。

![認証のメッセージフローを示すシーケンス図](/mulesoft/current/ja-jp/mule-gateway/_images/ldap-verification-invalid.png)

基本認証 - LDAP ポリシーは HTTP 401 状況コードをスローします。これは、認証ヘッダーが不正である、提供されていない、または無効であることを示します。