adutil の概要 - Active Directory ユーティリティ

適用対象:SQL Server - Linux

adutil ツールは、SQL Server on Linux およびコンテナー用の Windows Active Directory ドメインを構成および管理するためのコマンドライン インターフェイス (CLI) ユーティリティです。Active Directory を管理するために Windows と Linux マシンの間で切り替えを行う必要はありません。

adutil のサポートは、SQL Server のユース ケースのみに制限されます。

SQL Server on Linux またはコンテナーに対して Active Directory 認証を有効にする場合、adutil を使用する必要はありません。 「チュートリアル: SQL Server on Linux で Active Directory 認証を使用する」で説明されているように、ktpass などのユーティリティを使用することもできます。

adutil ツールは、一連のコマンドおよびサブコマンドとして設計されていて、さらに追加の入力としてフラグを指定することができます。 最上位の各コマンドは、管理機能のカテゴリを表します。 そのカテゴリ内の各サブコマンドは操作です。 この記事では、adutil をダウンロードして使い始める方法について説明します。

Secure Sockets Layer (SSL) 経由で LDAP 用に adutil を構成する

ライトウェイト ディレクトリ アクセス プロトコル (LDAP) ではなく、SSL 経由のライトウェイト ディレクトリ アクセス プロトコル (LDAPS) を使用する必要があります。 LDAP の詳細については、「ライト ウェイト ディレクトリ アクセス プロトコル (LDAP)」を参照してください。

adutil.json 構成ファイルで useLdaps オプションを true に設定することができます。そのファイルは、mssql ユーザーで実行した場合、/var/opt/mssql/.adutil/adutil.json にあります。 この JSON コード サンプルでは、設定を構成する方法を示します。

{
    "useLdaps": "true"
}

既定では、useLDAPS 設定は false に設定されています。 この設定を構成し、mssql-conf を使って keytab (キー テーブル) を作成するときは、必ずユーザー mssql として mssql-conf を実行してください。これは、次のコマンドを実行することで行うことができます。

sudo su mssql

mssql-conf を使って keytab を設定する方法について、「mssql-conf を使用して SQL Server サービスの keytab ファイルを作成する」をご覧ください。

adutil をインストールする

インストール時に使用許諾契約に同意しない場合は、adutil コマンドを初めて実行するときに、--accept-eula フラグを指定して実行する必要があります (すべてのディストリビューションで)。

  1. Microsoft Red Hat リポジトリ構成ファイルをダウンロードします。

    sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo
    
  2. 以前のプレビュー バージョンの adutil がインストールされている場合は、次のコマンドを使用して、古い adutil パッケージを削除します。

    sudo yum remove adutil-preview
    
  3. adutil をインストールするには次のコマンドを実行します。 ACCEPT_EULA=Y により、adutil の EULA が受け入れられます。 EULA はパス /usr/share/adutil/ に格納されます。

    sudo ACCEPT_EULA=Y yum install -y adutil
    

adutil を使用して Windows Active Directory を管理する

adutil のダウンロード先は必ず、既に Active Directory ドメインに参加しているホストとしてください。 また、kinit コマンドと特権ドメイン アカウントを使用して、Kerberos TGT (Ticket-Granting Ticket) を取得または更新する必要があります。 使用するアカウントには、ドメイン上でアカウントとサービス プリンシパル名 (SPN) を作成するためのアクセス許可が割り当てられている必要があります。

ここでは、adutil を使用して実行できるアクションの例をいくつか示します。 最上位のコマンドの一覧を表示するには、「adutil --help」と入力します。 このコマンドでは、Active Directory の管理と操作に使用できる最上位のコマンドが表示されます。

$ adutil --help
adutil - A general AD utility
  Usage:
    adutil [account|delegation|group|keytab|machine|ou|spn|user|config]
  Subcommands:
    account      Functions for generic account operations
    delegation   Functions for configuring delegation permissions
    group        Functions for group management
    keytab       Functions for keytab management
    machine      Functions for managing machine accounts
    ou           Functions for managing organizational units
    spn          Functions for service principal name (SPN) management
    user         Functions for user account management
    config       Functions for modifying adutil configuration
  Flags:
       --version       Displays the program version string.
    -h --help          Displays help with available flag, subcommand, and positional value parameters.
    -d --debug         Display additional debugging information when making LDAP/Kerberos calls.
       --accept-eula   Accepts the current EULA for adutil. This has no effect if the EULA has already been accepted.

次のレベルのコマンドに関するヘルプを表示するには、次の help オプションを実行できます。

$ adutil spn --help
spn - Functions for service principal name (SPN) management
  Usage:
    spn [add|addauto|delete|search|show]
  Subcommands:
    add       Adds the provided SPNs to an account
    addauto   Automatically generate SPNs based on SPN component inputs and add them to an account
    delete    Deletes the provided SPNs from an account
    search    Search for an SPN by name or list all SPNs in the directory
    show      Get the list of SPNs assigned to an account
  Flags:
    --version       Displays the program version string.
    -h --help          Displays help with available flag, subcommand, and positional value parameters.
    -d --debug         Display additional debugging information when making LDAP/Kerberos calls.
       --accept-eula   Accepts the current EULA for adutil. This has no effect if the EULA has already been accepted.
$ adutil spn search --help
search - Search for an SPN by name or list all SPNs in the directory
  Usage:
     search [name]
  Positional Variables:
    name   OPTIONAL: Name of the SPN to search for in the directory. * can be used as a wildcard
  Flags:
    --version       Displays the program version string.
    -h --help          Displays help with available flag, subcommand, and positional value parameters.
    -n --name          OPTIONAL: Name of the SPN to search for in the directory. * can be used as a wildcard
    -f --filter        OPTIONAL: Filter for the search (User,Machine,Group)
    -o --ouname        OPTIONAL: Distinguished name of OU in which SPNs should be searched. If omitted, the entire directory will be searched.
    -d --debug         Display additional debugging information when making LDAP/Kerberos calls.
       --accept-eula   Accepts the current EULA for adutil. This has no effect if the EULA has already been accepted.

サンプル

各コマンドはドキュメントに記載されているので、すぐに開始できます。 SQL Server on Linux とコンテナー用の Active Directory 認証を構成または管理するときに adutil を使用する一般的なアクティビティの一部を次に示します。

  • Active Directory でアカウントを作成します。

    adutil user create --name sqluser --distname CN=sqluser,CN=Users,DC=CONTOSO,DC=COM
    
  • アカウントまたはサービスに関連付けられた SPN を作成する:

    adutil spn addauto -n sqluser -s MSSQLSvc -H mymachine.contoso.com -p 1433
    
  • adutil を使用して keytab を作成する:

    adutil keytab createauto -k /var/opt/mssql/secrets/mssql.keytab -p 1433 -H mymachine.contoso.com --password 'P@ssw0rd' -s MSSQLSvc
    

コマンドを使用して、 adutilman adutil のリファレンス マニュアル ページを参照できます。