小编Jus*_*tin的帖子

由于双跳故障,委派受约束,远程Powershell请求中的SSPI SQL访问失败

我们正在尝试从远程服务器B上的serverA运行自动安装,该安装需要使用Windows身份验证与sql serverC进行通信。

Invoke-Command -ComputerName serverB -ScriptBlock {

    $conn = new-object System.Data.SqlClient.SqlConnection 'Data Source=ServerC;Initial Catalog=master;Integrated Security=SSPI'
    try
    {
        $conn.open()
    } finally {
        $conn | Remove-SQLConnection
    }

} -Credential $cred 
Run Code Online (Sandbox Code Playgroud)

但是,它无法返回:

”使用“ 0”参数调用“ Open”的异常:“用户'NT AUTHORITY \ ANONYMOUS LOGON'登录失败。”

我们使用以下方法解决了此问题:

Invoke-Command -ComputerName serverB -ScriptBlock { Register-PSSessionConfiguration -Name Ipswitch -RunAsCredential $using:cred -Force  } -Credential $cred
Run Code Online (Sandbox Code Playgroud)

但是我们更喜欢使用受约束的kerberos委托:

https://docs.microsoft.com/zh-cn/powershell/scripting/learn/remoting/ps-remoting-second-hop?view=powershell-6#resource-based-kerberos-constrained-delegation

我们尝试使用以下步骤执行kerberos委派:

##########################
#run on serverC
##########################
Add-WindowsFeature RSAT-AD-PowerShell

Import-Module ActiveDirectory


$serverB = Get-ADComputer serverB
$serverC = Get-ADComputer serverC

# Grant resource-based Kerberos constrained delegation
Set-ADComputer -Identity $serverC …
Run Code Online (Sandbox Code Playgroud)

sql-server powershell powershell-remoting kerberos-delegation

6
推荐指数
1
解决办法
133
查看次数