adutil 簡介 - Active Directory 工具

適用於:SQL Server 在 Linux 上

adutil 工具是一款命令列介面(CLI)工具,用於配置和管理SQL Server on Linux與容器的 Windows Active Directory 網域。 它消除了在 Windows 與 Linux 機器間切換來管理 Active Directory 的需求。

備註

adutil 的支援僅限於SQL Server的使用情境。 你也可以使用其他工具,如 ktpass來啟用Active Directory認證,詳見 教學:使用 SQL Server on Linux 使用Active Directory認證。

在開始之前,務必先將 adutil 下載到已經加入Active Directory網域的主機上。

adutil 工具設計成一系列命令和子命令,其中包含您指定為進一步輸入的額外旗標。 每個頂層指令代表一類行政功能。 在該類別中,每個子命令都是一項作業。 本文將教你如何下載並開始使用 Adutil

設定 adutil 以透過安全通訊端層 (SSL) 進行 LDAP

您應該使用透過 SSL 的輕量型目錄存取通訊協定 (LDAPS) 來取代輕量型目錄存取通訊協定 (LDAP)。 欲了解更多關於 LDAP 的資訊,請參閱輕量目錄存取協定(LDAP)。

你可以在useLdaps設定檔裡,將true選項設定為adutil.json。 當你以身分執行mssql時,設定檔位於/var/opt/mssql/.adutil/adutil.json。 此 JSON 程式碼範例示範如何進行設定:

{
    "useLdaps": "true"
}

根據預設,useLdapsfalse。 當你設定這個設定並使用 mssql-conf 建立 keytab(鍵表)時,務必以使用者身份執行 mssql-confmssql。 執行以下指令切換至使用者:mssql

sudo su mssql

要使用 mssql-conf 設定鍵卡,請參見 使用 mssql-conf 建立 SQL Server 服務鍵卡檔案。

安裝 adutil

如果你在安裝時不接受最終使用者授權協議(EULA),第一次執行 adutil 指令時,必須用 --accept-eula 該標誌執行(適用於所有發行版)。

  1. 下載 Microsoft Red Hat 儲存庫設定檔。

    雷爾 10

    sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/10/prod.repo
    

    雷爾 9

    sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/9/prod.repo
    

    RHEL 8

    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. 執行下列命令以安裝 adutilACCEPT_EULA=Y 會接受 adutil 的 EULA。 EULA 位於 /usr/share/adutil/

    sudo ACCEPT_EULA=Y yum install -y adutil
    

用 adutil 來管理Windows Active Directory

要使用 adutil,你需要使用 kinit 命令和特權網域帳號來取得或續訂 Kerberos 的 TGT(票證授權票)。 您使用的帳戶必須具有在網域上建立帳戶和服務主體名稱 (SPN) 的權限。

以下範例展示了你可以使用 adutil 執行的一些典型活動。 若要查看最上層命令清單,請鍵入 adutil --help

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.

要獲得較低階指令的幫助,請使用以下範例:

  • spn 命令:

    adutil spn --help
    
  • spn search 命令:

    adutil spn search --help
    

範例

每個命令都有說明,因此您可以立即開始使用。 以下是adutil在配置或執行SQL Server on Linux與容器Active Directory認證時常用的一些典型活動:

  • 在 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 建立金鑰表:

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

    警告

    你的密碼應該遵循SQL Server預設的password policy。 依預設,密碼長度必須至少有 8 個字元,並包含下列四種字元組合中其中三種組合的字元:大寫字母、小寫字母、以 10 為底數的數字以及符號。 密碼長度最多可達 128 個字元。 盡可能使用長且複雜的密碼。

欲了解更多資訊,請參閱使用 man adutil 參考手冊頁面。