Microsoft Entra Connect での SQL 接続の問題のトラブルシューティング

この記事では、Microsoft Entra Connect と SQL Server の間の接続に関する問題のトラブルシューティング方法について説明します。

次のスクリーンショットは、SQL Server が見つからない場合の一般的なエラーを示しています。

SQL エラー

トラブルシューティングの手順

[管理者として実行] を使用して PowerShell ウィンドウを開き、ADSyncTools のインストールとインポート PowerShell モジュールを開きます。

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module ADSyncTools
Import-Module ADSyncTools

Note

Install-Module は PowerShell 5.0 (WMF 5.0) またはそれ以降への更新が必要になります。
または PackageManagement PowerShell モジュール プレビュー - March 2016 for PowerShell 3.0/4.0 をインストールしてください

  • すべてのコマンドを表示: Get-Command *Sql* -Module ADSyncTools
  • PowerShell 関数を実行: 以下のパラメーターを指定した Connect-ADSyncToolsSqlDatabase
    • Server: SQL Server サーバー名。
    • Instance (省略可能): SQL Server インスタンス名と、必要に応じて、使用するポート番号。 既定のインスタンスを使用する場合は、このパラメーターを指定しないでください。
    • Port (省略可能): SQL Server ポート
    • UserName (省略可能): 接続するユーザー アカウント。空白のままにすると、現在ログオンしているアカウントが使用されます。 リモートの SQL Server に接続している場合、この UserName は Microsoft Entra Connect SQL 接続用に作成したカスタム サービス アカウントである必要があります。 Microsoft Entra Connect では、Microsoft Entra Connect 同期サービス アカウントを使用してリモート SQL Server に対する認証を行います。
    • Password (省略可能): 指定した UserName のパスワード。

この PowerShell 関数は、渡された資格情報、または現在のユーザーの資格情報を使用して、指定された SQL Server とインスタンスへのバインドを試みます。 SQL Server が見つからない場合、このスクリプトは SQL Browser サービスに接続を試み、有効になっているプロトコルとポートを決定します。

サーバー名のみを使用する例


PS C:\> Connect-ADSyncToolsSqlDatabase -Server SQL1.contoso.com
Resolving server address : SQL1.contoso.com
    InterNetworkV6 : fe80::6c90:a995:3e70:ef74%17
    InterNetworkV6 : 2001:4898:e0:66:6c90:a995:3e70:ef74
    InterNetwork : 10.91.26.143

Attempting to connect to SQL1 using a TCP binding for the default instance.
   Data Source=tcp:SQL1.contoso.com\;Integrated Security=True.ConnectionString
   Successfully connected.


StatisticsEnabled                : False
AccessToken                      : 
ConnectionString                 : Data Source=tcp:SQL1\;Integrated Security=True
ConnectionTimeout                : 15
Database                         : master
DataSource                       : tcp:SQL1.contoso.com\
PacketSize                       : 8000
ClientConnectionId               : 23e06ef2-0a38-4f5f-9291-da931de40375
ServerVersion                    : 13.00.4474
State                            : Open
WorkstationId                    : SQL1
Credential                       : 
FireInfoMessageEventOnUserErrors : False
Site                             : 
Container                        : 

サーバー名と SQL 名付きインスタンスの使用例:


PS C:\> Connect-ADSyncToolsSqlDatabase -Server SQL1.contoso.com -Instance SQLINSTANCE1
Resolving server address : SQL1.contoso.com
   InterNetwork: 10.0.100.24 

Attempting to connect to SQL1.contoso.com\SQLINSTANCE1 using a TCP binding.
   Data Source=tcp:SQL1.contoso.com\SQLINSTANCE1;Integrated Security=True
   Successfully connected.


StatisticsEnabled                : False
AccessToken                      : 
ConnectionString                 : Data Source=tcp:SQL1.contoso.com\SQLINSTANCE1;Integrated Security=True
ConnectionTimeout                : 15
Database                         : master
DataSource                       : tcp:SQL1.contoso.com\SQLINSTANCE1
PacketSize                       : 8000
ClientConnectionId               : 2b365b7a-4348-45f6-9314-d6b56db36dbd
ServerVersion                    : 13.00.4259
State                            : Open
WorkstationId                    : SQL1
Credential                       : 
FireInfoMessageEventOnUserErrors : False
Site                             : 
Container                        : 


到達できない SQL インスタンスの使用例。 これは、SQL Server Browser サービスに対してクエリを試み、使用可能な SQL インスタンスとそれぞれのポートを表示します。


PS C:\> Connect-ADSyncToolsSqlDatabase -Server SQL01.Contoso.com -Instance DEFAULT
Resolving server address : SQL01.Contoso.com
   InterNetwork: 10.0.100.24 

Attempting to connect to SQL01.Contoso.com\SQL using a TCP binding.
   Data Source=tcp:SQL01.Contoso.com\SQL;Integrated Security=True
Connect-ADSyncToolsSqlDatabase : Unable to connect using a TCP binding.  A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was 
not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance 
Specified) 
At line:1 char:1
+ Connect-ADSyncToolsSqlDatabase -Server SQL01.Contoso.com -Insta ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ConnectionError: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Connect-ADSyncToolsSqlDatabase
 
TROUBLESHOOTING: Attempting to query the SQL Server Browser service configuration on SQL01.Contoso.com. 

SQL browser response contained 2 instances.
Verifying protocol bindings and port connectivity...
SQLINSTANCE1    : Enabled - port 49823 is assigned and reachable through the firewall
SQL2019         : Enabled - port 50631 is assigned and reachable through the firewall

WHAT TO TRY NEXT: 

Each SQL instance must be bound to an explicit static TCP port and paired with an inbound firewall rule on SQL01.Contoso.com to allow connection. Review the TcpStatus field for each instance and take cor
rective action. 


InstanceName : SQLINSTANCE1
tcp          : 49823
TcpStatus    : Enabled - port 49823 is assigned and reachable through the firewall

InstanceName : SQL2019
tcp          : 50631
TcpStatus    : Enabled - port 50631 is assigned and reachable through the firewall


次のステップ