---
schema_version: "1"
id: 9291d447a55cf15a960a6435b020409e4e0a204578825df86729a5d6d1e8c3c8
title: LDAP Connector 3.6 の例
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/ldap-connector/3.6/ldap-connector-examples.md
canonical_url: https://docs.mulesoft.com/jp/ldap-connector/3.6/ldap-connector-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: e4f8183c5a8f1459e95749d693e26d89460ba54ac2b460ae737a8a7e33cb66ff
description: MuleSoft Documentation Site
release: "3.6"
latest: true
---
# LDAP Connector 3.6 の例

Lightweight Directory Access Protocol 用 Anypoint Connector (LDAP Connector) の使用例を次に示します。

- 組織単位にグループとユーザーを追加してから、そのユーザーとグループを削除する
- 一般的なトラストストアをセットアップする

## [](#add-delete-entry)組織単位へのグループとユーザーの追加および削除

次の例は、LDAP の ​**Add entry**​ 操作を使用してグループとユーザーを組織単位に追加し、​**Delete entry**​ 操作を使用してユーザーとグループを組織単位から削除する方法を示しています。

次のスクリーンショットは、この例の Studio アプリケーションフローを示しています。

![ユーザーを追加および削除するためのフロー](/mulesoft/current/ja-jp/ldap-connector/3.6/_images/ldap-usecase-flow.png)

### [](#組織単位にグループとユーザーを追加する)組織単位にグループとユーザーを追加する

組織単位にグループとユーザーを追加する手順は、次のとおりです。

1. Anypoint Studio で新しい Mule プロジェクトを作成します。
2. `mule-artifact.properties`​ ファイルに次のプロパティを追加します。
    
    ```text
    config.principal.dn=<DN>
    config.password=<Password>
    config.url=<URL>
    ```
3. プロジェクトの ​`src/main/resources`​ ディレクトリに ​`mule-artifact.properties`​ ファイルを置きます。
4. **\[Mule Palette (Mule パレット)\]**​ ビューから、​**\[HTTP\]**​ をクリックして ​**\[Listener\]**​ ソースをキャンバスにドラッグします。
5. \[Listener (リスナー)\] プロパティウィンドウで、​**\[Listener\]**​ ソースの表示名を ​`HTTP`​ に変更します。
6. **\[Connector configuration (コネクタ設定)\]**​ 項目の横にある ​**\[+\]**​ をクリックし、グローバル要素を追加します。
7. デフォルトを受け入れます。
8. \[Listener (リスナー)\] プロパティウィンドウで、​**\[Path (パス)\]**​ 項目値を ​`/`​ に設定します。
9. **\[Mule Palette (Mule パレット)\]**​ ビューから、​**\[Core (コア)\]**​ を選択して ​**\[Transform Message\]**​ コンポーネントを ​**\[HTTP\]**​ の横にドラッグします。
10. **\[Output (出力)\]**​ セクションで、既存のテキストを次の DataWeave スクリプトに置き換えます。
    
    ```java
    %dw 2.0
    output application/java
    ---
    {
    	dn : "ou=DevOpsGroup," ++ attributes.queryParams.dn,
    	ou : "DevOpsGroup",
    	objectclass : ["top", "organizationalUnit"]
    }
    ```
11. **\[Mule Palette (Mule パレット)\]**​ ビューから、​**\[LDAP\]**​ を選択して ​**\[Add entry\]**​ 操作を ​**\[Transform Message\]**​ コンポーネントの横にドラッグし、LDAP グループの追加を開始します。
12. コネクタ設定項目の横にある ​**\[+\]**​ をクリックし、新しいグローバル要素を追加します。
13. 次のようにグローバル要素を設定します。
    
    <table class="tableblock frame-all grid-all fit-content">
<colgroup>
<col>
<col>
<col>
</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"><p class="tableblock">Name (名前)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">設定の名前。</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>LDAP_Configuration</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Principal DN (プリンシパル DN)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ユーザー識別名 (DN)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>${config.principal.dn}</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Password (パスワード)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ユーザーパスワード</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>${config.password}</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">URL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">LDAP サーバーに接続する URL</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>${config.url}</code></p></td>
</tr>
</tbody>
</table>
14. **\[Test Connection (接続をテスト)\]**​ をクリックして、Mule が LDAP サーバーインスタンスに接続できることを確認します。
15. 次のように接続結果を処理します。
    
    - 正常に接続できた場合は、​**\[OK\]**​ をクリックして設定を保存します。
    - 接続に失敗した場合は、誤った項目値を確認して修正し、もう一度テストを実行します。
16. LDAP Connector プロパティウィンドウに戻り、​**Add entry**​ 操作に必要なパラメーターを設定します。
    
    <table class="tableblock frame-all grid-all fit-content">
<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"><p class="tableblock">Display Name (表示名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Add Group Entry to LDAP Directory</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="2"><p class="tableblock">Basic Settings (基本設定)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Connector configuration (コネクタ設定)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">以前に作成した LDAP Connector グローバル要素</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="2"><p class="tableblock">General (一般)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Entry (エントリ)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>payload</code>​ (デフォルト値)</p></td>
</tr>
</tbody>
</table>
17. **\[Mule Palette (Mule パレット)\]**​ ビューから、​**\[Core (コア)\]**​ を選択して ​**\[Transform Message\]**​ コンポーネントを ​**\[Add Group Entry to the LDAP directory (LDAP ディレクトリへのグループエントリの追加)\]**​ の横にドラッグします。
18. **\[Output (出力)\]**​ セクションで、既存のテキストを次の DataWeave スクリプトに置き換えます。
    
    ```java
    %dw 2.0
    output application/java
    ---
    {
    	dn : "cn=Test User,ou=DevOpsGroup," ++ attributes.queryParams.dn,
    	uid : "testUser",
    	cn : "Test User",
    	sn : "User",
    	userPassword : "test1234",
    	objectclass : ["top", "person", "organizationalPerson", "inetOrgPerson"]
    }
    ```
19. **\[Mule Palette (Mule パレット)\]**​ ビューから、​**\[LDAP\]**​ を選択して ​**\[Add entry\]**​ 操作を ​**\[Transform Message\]**​ の横にドラッグし、LDAP ユーザーの追加を開始します。
20. LDAP Connector プロパティエディターで、次のようにパラメーターを設定します。
    
    <table class="tableblock frame-all grid-all fit-content">
<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"><p class="tableblock">Display Name (表示名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Add User Entry to LDAP Directory</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="2"><p class="tableblock">Basic Settings (基本設定)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Connector configuration (コネクタ設定)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">以前に作成した LDAP Connector グローバル要素</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="2"><p class="tableblock">General (一般)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Entry (エントリ)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>payload</code>​ (デフォルト値)</p></td>
</tr>
</tbody>
</table>

### [](#組織単位からグループとユーザーを削除する)組織単位からグループとユーザーを削除する

組織単位にグループとユーザーが正常に追加されたら、LDAP Connector を使用してそれらを削除します。

1. **\[Mule Palette (Mule パレット)\]**​ ビューから、​**\[LDAP\]**​ を選択して ​**\[Delete entry\]**​ 操作をキャンバスの ​**\[Add User Entry to LDAP Directory (LDAP ディレクトリへのユーザーエントリの追加)\]**​ の横にドラッグします。
2. LDAP Connector プロパティエディターで、次のようにパラメーターを設定します。
    
    <table class="tableblock frame-all grid-all fit-content">
<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"><p class="tableblock">Display Name (表示名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Delete User Entry from LDAP Directory</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="2"><p class="tableblock">Basic Settings (基本設定)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Connector configuration (コネクタ設定)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">以前に作成した LDAP Connector グローバル要素</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="2"><p class="tableblock">General (一般)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">DN</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>#['cn=Test User,ou=DevOpsGroup,' ++ attributes.queryParams.dn]</code></p></td>
</tr>
</tbody>
</table>
3. 別の ​**\[Delete entry\]**​ 操作を最初の操作の横にドラッグして、LDAP グループエントリの削除を開始します。
    
    <table class="tableblock frame-all grid-all fit-content">
<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"><p class="tableblock">Display Name (表示名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Delete Group Entry from LDAP Directory</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="2"><p class="tableblock">Basic Settings (基本設定)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Connector configuration (コネクタ設定)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">以前に作成した LDAP Connector グローバル要素</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" colspan="2"><p class="tableblock">General (一般)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">DN</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>#['ou=DevOpsGroup,' ++ attributes.queryParams.dn]</code></p></td>
</tr>
</tbody>
</table>
4. **\[Transform Message\]**​ コンポーネントを ​**\[Delete Group Entry from LDAP Directory (LDAP ディレクトリからのグループエントリの削除)\]**​ の横にドラッグします。
5. ペイロードを「Flow Successfully Completed」 (フロー正常完了) に設定します。

### [](#アプリケーションをテストする)アプリケーションをテストする

アプリケーションをテストする手順は、次のとおりです。

1. プロジェクトを保存します。
2. プロジェクトを Mule アプリケーションとして実行します。
3. PUT コマンドを次の URL に送信します。
    
    `http://localhost:8081/?dn=mulesoft,dc=orgrequest`

### [](#例の-xml)例の XML

この例のフローをすばやく Mule アプリケーションに読み込むには、次のコードを Studio XML エディターに貼り付けます。

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ldap="http://www.mulesoft.org/schema/mule/ldap" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/ldap
http://www.mulesoft.org/schema/mule/ldap/current/mule-ldap.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="74b34b41-4e8b-4b96-adec-da917b183083" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<ldap:config name="LDAP_Configuration" doc:name="LDAP Configuration" doc:id="2e1caebb-d041-47ec-9513-69c140c78700" >
		<ldap:basic-connection authDn="${config.principal.dn}" authPassword="${config.password}" url="${config.url}" />
	</ldap:config>
	<flow name="ldap-examplesFlow" doc:id="dc01fbb8-1e2c-4255-be17-46309cdbef07" >
		<http:listener doc:name="HTTP" doc:id="180e5809-d508-498c-a74f-97d93afc98f8" config-ref="HTTP_Listener_config" path="/"/>
		<ee:transform doc:name="Transform Message" doc:id="183ca95a-dcc2-448f-8bba-26f7295fb1e4" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
{
	dn : "ou=DevOpsGroup," ++ attributes.queryParams.dn,
	ou : "DevOpsGroup",
	objectclass : ["top", "organizationalUnit"]
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<ldap:add doc:name="Add Group Entry to LDAP Directory" doc:id="95d60199-e087-4fe1-afa7-1c035fdd3aec" config-ref="LDAP_Configuration"/>
		<ee:transform doc:name="Transform Message" doc:id="0e96e606-48be-4ba0-9266-242bd9911184">
			<ee:message>
				<ee:set-payload><![CDATA[{
	dn : "cn=Test User,ou=DevOpsGroup," ++ attributes.queryParams.dn,
	uid : "testUser",
	cn : "Test User",
	sn : "User",
	userPassword : "test1234",
	objectclass : ["top", "person", "organizationalPerson", "inetOrgPerson"]
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<ldap:add doc:name="Add User Entry to LDAP Directory" doc:id="28c98048-0ba6-4a36-92df-49d437303217" config-ref="LDAP_Configuration"/>
		<ldap:delete doc:name="Delete User Entry from LDAP Directory" doc:id="07e7141a-03d9-4565-bbca-8a4b03cbb6ee" config-ref="LDAP_Configuration" dn="#['cn=Test User,ou=DevOpsGroup,' ++ attributes.queryParams.dn]"/>
		<ldap:delete doc:name="Delete Group ENtry from LDAP Directory" doc:id="892dca59-86a3-40a2-b758-09560fb95383" config-ref="LDAP_Configuration" dn="#['ou=DevOpsGroup,' ++ attributes.queryParams.dn]"/>
		<ee:transform doc:name="Transform Message" doc:id="5dc391aa-87b1-4e84-97e5-71dc5f8daa22" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
{
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
	</flow>
</mule>
```

## [](#set-up-common-truststore)一般的なトラストストアをセットアップする

次の例は、カスタムトラストストアを使用する TLS 設定を含めるように前の例を変更する方法を示しています。

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content">このカスタムトラストストア機能は FIPS 準拠ではありません。</td></tr></tbody></table>

カスタムトラストストアをセットアップする手順は、次のとおりです。

1. 前の例の手順に従います。
2. 次のプロパティを ​`mule-artifact.properties`​ ファイルに追加して LDAP ログイン情報を保持します。
    
    ```text
    config.principal.dn=<DN>
    config.password=<Password>
    config.url=<URL>
    ```
3. プロジェクトの ​`src/main/resources`​ ディレクトリに ​`mule-artifact.properties`​ ファイルを置きます。
4. XML コードで次の要素を見つけます。
    
    ```xml
     <ldap:conf name=:LDAP_configuration" doc:name="LDAP Configuration"
     .
     .
     .
     </ldap:config
    ```
5. 見つかった要素を次のコードで上書きします。
    
    ```xml
    <ldap:config name="LDAP_Configuration">
      <ldap:tls-connection
        authDn="${config.principal.dn}}"
        authPassword="${config.password}"
        url="${config.url}"
        trustStorePath="path_to_truststore_jks_file"
        trustStorePassword="changeit" />
    ```

### [](#run-time)アプリケーションをテストする

アプリケーションをテストする手順は、次のとおりです。

1. プロジェクトを保存します。
2. プロジェクトを Mule アプリケーションとして実行します。
3. PUT コマンドを次の URL に送信します。
    
    `http://localhost:8081/?dn=mulesoft,dc=orgrequest`

## [](#関連情報)関連情報

- [MuleSoft ヘルプセンター](https://help.mulesoft.com)