tags:

views:

460

answers:

2

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?

A: 

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), 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

Richard
A: 

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

Garett