Why I get Access Denied Error using WMI Connection?

0

this is a similar error all around the internet but I am not able to reason out why this can happen in my case. I am trying to use WMI for remotely installing windwos services from my XP client machine. I use,

    ConnectionOptions options = new ConnectionOptions();
    options.EnablePrivileges = true;
    options.Impersonation = ImpersonationLevel.Impersonate;
    options.Username = "domainName\userName";
    options.Password = "pwd";
    string path = string.Format("\\\\{0}\\root\\cimv2", machineName);
    ManagementScope scope = new ManagementScope(path, options);
    scope.Connect();

I get 'Access is denied. (Exception from HRESULT: 0x80070005)' error. I use a windows XP SP3 and trying to connect to windows server 2003.

I found out these but I did check all of these:

  1. User account not admin - The user account is a local admin. I can use the same account, to do a instalutil and create services in that machine. This is the account underwhich my application services run.

  2. dcomcnfg and check Enable DCOM - This is already enabled.

  3. Changed Enabled Previliges and Impersonation properties in ConnectionOptions. But this doesnt help.

  4. Firewall settings - The error message number doesnt say this. But, the machine is withing the same domain as the XP client.

c#
wmi
dcom
asked on Stack Overflow Sep 26, 2011 by Everything Matters • edited Sep 25, 2018 by Kiquenet

1 Answer

0

I figured this out. The account that I used to login remotely (via mstsc) and install/uninstall services was NOT a local admin account. It was surprising because, I used the same account to install services in that machines, so assumed it would be a local admin. When I added the account to local admin, the WMI connectivity also worked. Hence, for remotely connecting to the machine, u need to use a local admin account.

answered on Stack Overflow Sep 30, 2011 by Everything Matters • edited Dec 12, 2014 by Rahul Nikate

User contributions licensed under CC BY-SA 3.0