

# Babelfish で Active Directory セキュリティグループを使用して Kerberos 認証を設定する
<a name="babelfish-kerberos-securityad"></a>

Babelfish バージョン 4.2.0 以降では、Active Directory セキュリティグループを使用して Babelfish の kerberos 認証を設定できます。Active Directory を使用して kerberos 認証の設定を完了するための前提条件は次のとおりです。
+  「[Babelfish を使用した Kerberos 認証](babelfish-active-directory.md)」に記載されているすべてのステップに従う必要があります。
+ DB インスタンスが Active Directory に関連付けられていることを確認します。これを確認するために、コンソールで、または [describe-db-instances](https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-instances.html) AWS CLI コマンドを実行して、ドメインメンバーシップのステータスを表示できます。

  DB インスタンスのステータスは kerberos 対応である必要があります。ドメインメンバーシップの理解についての詳細は、「[ドメインのメンバーシップを理解する](postgresql-kerberos-managing.md#postgresql-kerberos-managing.understanding)」を参照してください。
+ NetBIOS ドメイン名と DNS ドメイン名の間のマッピングを確認するには、次のクエリを使用します。

  ```
  SELECT netbios_domain_name, fq_domain_name FROM babelfish_domain_mapping;
  ```
+ 先に進む前に、個々のログインを使用した Kerberos 認証が期待どおりに機能することを確認します。Active Directory ユーザーとして Kerberos 認証を使用する接続は成功する必要があります。問題が発生した場合は、「[頻繁に発生するエラー](babelfish-active-directory.md#babelfish-active-directory-errors)」を参照してください。

## pg\_ad\_mapping 拡張機能のセットアップ
<a name="babelfish-kerberos-securityad-setpgextn"></a>

 「[pg\_ad\_mapping 拡張機能のセットアップ](AD.Security.Groups.md#AD.Security.Groups.Setup)」に記載されているすべてのステップに従う必要があります。拡張機能がインストールされていることを確認するには、TDS エンドポイントから次のクエリを実行します。

```
1> SELECT extname, extversion FROM pg_extension where extname like 'pg_ad_mapping';
2> GO
extname       extversion
------------- ----------
pg_ad_mapping 0.1

(1 rows affected)
```

## グループログインの管理
<a name="babelfish-kerberos-securityad-managing"></a>

 「[ログインの管理](babelfish-active-directory.md#babelfish-active-directory-login-managing)」に記載されている手順に従って、グループログインを作成します。メンテナンスを容易にするために、ログイン名は Active Directory (AD) セキュリティグループ名と同じにすることをお勧めしますが、必須ではありません。例えば、次のようになります。

```
CREATE LOGIN [corp\accounts-group] FROM WINDOWS [WITH DEFAULT_DATABASE=database]
```

## 監査とログ記録
<a name="babelfish-kerberos-securityad-audit"></a>

 AD セキュリティプリンシパル ID を決定するには、次のコマンドを使用します。

```
1> select suser_name();
2> GO
suser_name
----------
corp\user1

(1 rows affected)
```

現在、AD ユーザー ID はログに表示されません。`log_connections` パラメータを有効にすると、DB セッションの確立をログに記録できます。詳細については、「[log\_connections](https://docs.aws.amazon.com/prescriptive-guidance/latest/tuning-postgresql-parameters/log-connections.html)」を参照してください。出力には、次の例に示すように、プリンシパルとして AD ユーザー ID が含まれます。この出力に関連付けられたバックエンド PID は、属性アクションを実際の AD ユーザーに戻すのに役立ちます。

```
bbf_group_ad_login@babelfish_db:[615]:LOG: connection authorized: user=bbf_group_ad_login database=babelfish_db application_name=sqlcmd GSS (authenticated=yes, encrypted=yes, principal=user1@CORP.EXAMPLE.COM)
```