无法在 C# 中从 XP Pro 计算机到另一台计算机(不在域中,同一工作组中)建立 WMI 连接
我有两台 XP Pro SP3 机器。 我在两者中都禁用了防火墙。 工作组名称是 WORKGROUP。 我有一个管理员帐户,两者的用户名/密码相同。 我的连接代码如下:
ConnectionOptions options = new ConnectionOptions();
options.Username = myUsername;
options.Password = myPassword;
options.Authority = "ntdlmdomain:WORKGROUP"; // Commenting this or not makes no difference
ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", hostname, Namespace), options);
scope.Connect();
我总是收到 System.UnauthorizedAccessException
,其中包含以下文本:
"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
上面的代码在属于同一 AD 域的两台计算机之间运行。 我究竟做错了什么?
I have two XP Pro SP3 machines. I disabled the firewall in both. The workgroup name is WORKGROUP. I have an administrator account with identical username/password in both. My code to connect is the following:
ConnectionOptions options = new ConnectionOptions();
options.Username = myUsername;
options.Password = myPassword;
options.Authority = "ntdlmdomain:WORKGROUP"; // Commenting this or not makes no difference
ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\{1}", hostname, Namespace), options);
scope.Connect();
I always get a System.UnauthorizedAccessException
with the text:
"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
The above code works between two machines that are part of the same AD domain. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题与 WMI 远程访问有关,与 C# 无关(我希望您使用其他 WMI 查询工具也会遇到相同的错误 - 例如,WBEMtest),在服务器故障上多次出现:请参阅 http://www.google.com/search?q =site%3Aserverfault.com+wmi+access+denied&ie=utf-8&oe=utf-8&aq=t
This question, which is all about WMI remote access and nothing to do with C# (I expect you would get the same error with other WMI query tools - for example, WBEMtest), has come up multiple times on Server Fault: see http://www.google.com/search?q=site%3Aserverfault.com+wmi+access+denied&ie=utf-8&oe=utf-8&aq=t
这是一个常见的 WMI 问题。 请参阅 WMI 常见问题解答,或有关 保护远程 WMI 连接。
This is a common WMI issue. See the WMI FAQ, or the documentation on securing remote WMI connections.
调整本地安全策略和服务以允许每个人以及文件夹内选项禁用共享。 完成此操作后,我能够通过 WMI 连接到工作组中的两台 XP 计算机。
Adjust the local security policy and services to allow everyone and also in-folder options to disable sharing. After doing this I was able to connect to two XP machines in the workgroup by WMI.