使用管理范围的远程连接



我正在尝试通过Management Scope的帮助从本地机器连接远程系统。

我尝试的是:

我的代码如下,

 ConnectionOptions con= new ConnectionOptions();
 con.Username = strUsername;
 con.Password = strPassword;
 con.Impersonation = ImpersonationLevel.Impersonate;
 con.EnablePrivileges = true;
 ManagementScope ManagementScope1 = new ManagementScope(string.Format("\\{0}\root\cimv2", strIP), con);
 ManagementScope1.Connect();

My Problem is

使用前面的代码,我可以连接到远程系统时,它有一些用户名和密码。(strUsername =" User", strPassword="Welcome")

但在空白密码的情况下(strUsername = "User", strPassword = "),我得到的错误命名为"访问被拒绝"。连接的远程系统对密码没有保护。

远程系统用户给了各种权限访问机器,但仍然面临这个奇怪的问题。

请让我知道我哪里出错了。非常感谢任何帮助。

如果您想使用当前登录的用户访问远程WMI,您必须将null作为Username传递。

如果连接将使用当前登录的用户,则

null;否则,表示用户名的字符串。默认值为空。

来源:http://msdn.microsoft.com/en-US/library/system.management.connectionoptions.username (v = vs.110) . aspx

最新更新