.Net - 当 SQL 服务器位于另一个 VM 上时使用 WMI 进行远程 BizTalk 服务器监控

.Net - Remote BizTalk server monitoring using WMI when the SQL server is located on another VM

我已经创建了一个 windows 服务来监视接收位置和发送端口事件,即 start/stop/enabled/disabled/enlisted/unenlisted 使用 WMI ManagementScope class 范围的本地 BizTalk 服务器计算机:

string strScope = @"\.\root\MicrosoftBizTalkServer";

但是当我尝试指向远程 machine/server 以使用以下方法捕获事件时:

string strScope = string.Format(@"\{0}\root\MicrosoftBizTalkServer", node.Address);

我收到一个奇怪的 WMI 错误。我试图指向的典型远程计算机是一个类似的 windows 服务器,有一个小区别,即它的 BizTalk 服务器指向位于网络中另一台服务器上的 SQL 服务器。

经过大量谷歌搜索和搜索后,我发现了一些信息,指出失败的可能原因是 classic "Double-hop" 问题,当我们尝试访问远程 BizTalk 服务器时,它会发生SQL 服务器在另一台机器上。

在 visual studio 中,我没有获得足够的错误信息,因此我尝试使用 windows 内置工具 "wbemtest.exe" 来解决正在发生的问题,结果发现了一个很长的错误消息如下:

BizTalk Server cannot access SQL server. This could be due to one of the following reasons: \n1. Access permissions have been denied to the current user. Either log on as a user that has been granted permissions to SQL and try again, or grant the current user permission to access SQL Server. \n2. The SQL Server does not exist or an invalid database name has been specified. Check the name entered for the SQL Server and database to make sure they are correct as provided during SQL Server installation. \n3. The SQL Server exists, but is not currently running. Use the Windows Service Control Manager or SQL Enterprise Manager to start SQL Server, and try again. \n4. A SQL database file with the same name as the specified database already exists in the Microsoft SQL Server data folder. \n \nInternal error from OLEDB provider: \"Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.\""

我尝试在管理服务 -> 组件服务下使用防火墙和 DCOM 设置,但没有任何设置可以让我通过 "impersonation" 传递我的用户凭据并检索接收位置/发送端口信息。

请分享实际解决此问题的 workaround/solution/configuration 设置。

这只是一个双跃点问题,您遇到的问题是因为您正在尝试 运行 服务并访问远程服务器 BizTalk 服务器,然后该服务器正在尝试登录远程 SQL 服务器。您的凭据仅到达 BizTalk 服务器,但 BizTalk 服务器不会将您的凭据传递到另一台服务器。

参考这个link解决 Similar Issue

经过大量研究和深入研究,解决方案是通过为非域管理员启用/配置 Kerberos 身份验证来实现的。服务帐户用户和参与通信的机器,即客户端(发送基于 WMI 的请求的机器)、Biztalk 节点(响应基于 WMI 的请求的机器)和 SQL 服务器节点(机器托管 / 运行 SQL 服务器数据库引擎服务和最重要的 Biztalk 数据库,包括消息框、跟踪、管理和 SSO)。

这一切都是在一个域下完成的,并且为 Biztalk 节点和 SQL 服务器节点以及使用的服务帐户设置了委派。

已为 WMI 服务帐户授予 DCOM 权限,并已设置 DTC(分布式事务处理协调器)权限。

已生成适当的 SPN 并已向服务帐户授予适当的 SQL 服务器权限,以委派模式启动 WMI 请求。

已使用以下 SQL 查询验证是否为特定服务帐户启用了 Kerberos:

select session_id,net_transport,client_net_address,auth_scheme from sys.dm_exec_connections