我正在嘗試設定 PowerShell 腳本以在我們的 Azure SQL Server 資料庫上啟用 Always Encrypted。我正在關注本指南,它提供了以下示例代碼:
# Import the SqlServer module
Import-Module "SqlServer"
# Connect to your database
# Set the valid server name, database name and authentication keywords in the connection string
$serverName = "<Azure SQL server name>.database.windows.net"
$databaseName = "<database name>"
$connStr = "Server = " $serverName "; Database = " $databaseName "; Authentication = Active Directory Integrated"
$database = Get-SqlDatabase -ConnectionString $connStr
# List column master keys for the specified database.
Get-SqlColumnMasterKey -InputObject $database
但是,我在使資料庫連接正常作業時遇到了問題。從所Get-SqlDatabase使用的 SqlServer 模塊中的命令似乎不支持通過 MFA 登錄。我們公司已經強制執行這種型別的登錄,所以我似乎無法找到解決方法。
運行時Get-SqlDatabase -ConnectionString 'Server=myserver.database.windows.net; Database=myDB; Authentication=Active Directory Interactive;'我收到以下錯誤:
找不到“ActiveDirectoryInteractive”的身份驗證提供程式。
SqlServer 模塊是否缺乏支持 MFA 登錄的能力?還是我錯過了其他東西?
uj5u.com熱心網友回復:
Get-SqlDatabaseCmdlet 使用System.Data.SqlClient其中根據以下檔案在身份驗證關鍵字中支持的值。
有效值為:
- 活動目錄集成
- 活動目錄密碼
- 密碼
Active Directory 集成:要使用此身份驗證模式,您需要將本地 Active Directory 聯合身份驗證服務 (ADFS) 與云中的 Azure Active Directory 聯合
Active Directory 密碼:authentication=ActiveDirectoryPassword 可用于使用 Azure AD 用戶名和密碼連接到 Azure SQL 資料庫/突觸分析。
Sql 密碼:Use authentication=SqlPassword使用用戶名/用戶和密碼屬性連接到 SQL Server。
如果要使用 MFA 通過 PowerShell 對 Sql Server 進行Active Directory Interactive身份驗證,則需要在身份驗證關鍵字中使用不支持的system.data.sqlclient
Active Directory Interactive:authentication=ActiveDirectoryInteractive可用于使用互動式身份驗證流(多因素身份驗證)連接到 Azure SQL 資料庫/突觸分析
請注意,System.Data.SqlClient驅動程式以及Get-SqlDatabase cmdlet不支持所有 Azure AD 身份驗證方法。如果支持的方法在您的環境中都不起作用,則使用 SQL 身份驗證可能是唯一的選擇。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/358337.html
