无法在 C# 中从 XP Pro 计算机到另一台计算机(不在域中,同一工作组中)建立 WMI 连接

发布于 2024-07-25 23:38:53 字数 702 浏览 2 评论 0原文

我有两台 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

囚我心虐我身 2024-08-01 23:38:53

这个问题与 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

心病无药医 2024-08-01 23:38:53

这是一个常见的 WMI 问题。 请参阅 WMI 常见问题解答,或有关 保护远程 WMI 连接

This is a common WMI issue. See the WMI FAQ, or the documentation on securing remote WMI connections.

蹲墙角沉默 2024-08-01 23:38:53

调整本地安全策略和服务以允许每个人以及文件夹内选项禁用共享。 完成此操作后,我能够通过 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文