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

Posted by JCCyC on Stack Overflow See other posts from Stack Overflow or by JCCyC
Published on 2009-07-02T20:59:14Z Indexed on 2010/03/26 12:03 UTC
Read the original article Hit count: 162

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about wmi