我想在使用WMI查询远程计算机上的数据时使用Windows当前凭据,但在许多示例中我发现我必须使用Connection对象,它需要您提供用户名,密码和验证用户名和密码的权限如下图所示:
Dim connection As New ConnectionOptions
connection.Username = userNameBox.Text
connection.Password = passwordBox.Text
connection.Authority = "ntlmdomain:MyDomain"
Dim scope As New ManagementScope( _
"\\RemoteMachine\root\CIMV2", connection)
scope.Connect()
我想绕过这些输入并使用当前的Windows登录凭据,有什么办法吗?
答案 0 :(得分:2)
这是'使用Windows凭据的连接选项的C#示例。
ConnectionOptions connectionOptions = new ConnectionOptions
{
Authentication = AuthenticationLevel.PacketPrivacy,
Impersonation = ImpersonationLevel.Impersonate
};