JCCyC
JCCyC

Reputation: 16622

Unable to make WMI connection from XP Pro machine to another (not in domain, same workgroup) in C#

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?

Upvotes: 2

Views: 1654

Answers (3)

Suraj Yadav
Suraj Yadav

Reputation: 1

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.

Upvotes: 0

Richard
Richard

Reputation: 109005

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

Upvotes: 2

Garett
Garett

Reputation: 16828

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

Upvotes: 0

Related Questions