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

# AD/LDAP Connector のテスト環境を設定する

> Active Directory ドメイン コントローラーの作成方法とテスト方法について説明します。

クラウド上にデプロイした仮想マシン (VM) に最小構成の AD Domain Controller をインストールすることで、テスト環境を構築できます。VM は任意のクラウドプラットフォームで実行できます。この例では、Microsoft Azure 上での設定方法を示します。

1. [Azure Management](https://azure.microsoft.com/en-us/features/azure-portal/) コンソールで仮想マシンを作成します。
2. 新しい VM の **ENDPOINTS** タブをクリックし、**Remote Desktop** エンドポイントの **PUBLIC PORT** を控えます。
3. Microsoft Remote Desktop クライアント (Windows または Mac) またはお好みのクライアント (Linux システム用の [rdesktop](http://www.rdesktop.org/) など) を開きます。VM への新しい接続を作成します。
4. 接続を開き、Remote Desktop クライアントに表示される証明書の警告は無視します。ローカル ネットワーク上の PC、デバイス、コンテンツを検出するかどうかを求められた場合は、**No** を選択します。
5. Windows タスク バーの PowerShell アイコンをクリックして **PowerShell Command Prompt** を開きます。ADDS をインストールします。
6. サーバーを、`mycompany.local` という FQDN を管理するドメイン コントローラーに昇格させます。
7. **SafeModeAdministratorPassword** の入力を求められたら、VM の作成時に使用した Administrator パスワードを入力します。Enter キーを押して続行します。昇格スクリプトが実行され、VM は自動的に再起動します。
8. テスト用のグループとユーザーを追加します。Remote Desktop クライアントを使って VM にログインし、PowerShell Command Prompt を開きます。次のスクリプトを実行します。

   ```text lines theme={null}
   > New-ADGroup -Name "Accounting" -GroupScope "DomainLocal"
   > New-ADGroup -Name "IT" -GroupScope "DomainLocal"

   > New-ADUser -GivenName Bob -Surname Johnson -Name "Bob Johnson" -SamAccountName bob.johnson -Enabled $True -AccountPassword (ConvertTo-SecureString "Pass@word1!" -AsPlainText -force) -PasswordNeverExpires $True
   > New-ADUser -GivenName Mary -Surname Smith -Name "Mary Smith" -SamAccountName mary.smith -Enabled $True -AccountPassword (ConvertTo-SecureString "Pass@word1!" -AsPlainText -force) -PasswordNeverExpires $True

   > Add-ADGroupMember -Identity Accounting -Members "bob.johnson", "mary.smith"
   > Add-ADGroupMember -Identity IT -Members "mary.smith"
   ```

## AD/LDAP Connector をインストールして設定する

1. [Auth0 Dashboard > Authentication > Enterprise](https://manage.auth0.com/#/connections/enterprise) に移動し、`auth0-test-ad` という名前の新しい **Active Directory/LDAP** 接続を作成します。手順の最後で生成される **Ticket URL** は、必ずコピーしておいてください。
2. VM で **Internet Explorer Enhanced Security Configuration** を無効にします。
3. 手順 1 で保存した **Ticket URL** を使って **Internet Explorer** を開きます。
4. ブラウザーの指示に従って **Connector** をダウンロード、インストール、設定します。LDAP サービスアカウントの入力を求められたら、VM 用に作成した管理者アカウントを使用します: **Username**: `mycompany\ad-admin,` **Pas**sword:  (前と同じ) 。
5. Connector の設定とインストールが完了したら、サーバーを再起動します。
6. Remote Desktop を使って VM に再度ログインします。
7. `http://localhost:8357/` にアクセスして Connector の設定サイトを開きます。
8. **Connector** がユーザーを見つけられることを確認します。

   1. **Search** タブをクリックします。
   2. 「Find User by Login」に `mary.smith` と入力します。
   3. **Search** をクリックします。そのユーザーの AD プロファイルデータを含む JSON が返されるはずです:

## Auth0 から認証をテストする

Auth0 アカウントを使用してすべてが正しく動作していることを確認するため、Auth0 で **Default App** が新しい **Active Directory / LDAP** 接続を使用するように設定し、`/authorize` endpoint を使って認証フローを開始します。

1. [Auth0 Dashboard > Applications > Applications](https://manage.auth0.com/#/applications) に移動します。

2. **Default App** の **Settings** アイコンをクリックします。

3. アプリケーションの **Allowed Callback URLs** の一覧に `http://jwt.io` を追加します。

4. **Connections** タブをクリックします。

5. **Enterprise** で、`auth0-test-ad` の **Active Directory / LDAP** 接続を有効にします。

6. 次のリンクをブラウザーで開き、認証フローをテストします。

7. ディレクトリで作成されたテストユーザーのいずれかでログインします。

   * ユーザー名: `mary.smith` または `bob.johnson`
   * パスワード: `Pass@word1!`

8. すべてが正しく動作していれば、JWT.io の Web サイトにリダイレクトされ、生成された JWT の内容を確認できます。
