开发者

Why I get Access Denied Error using WMI Connection?

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();
开发者_如何学Python    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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜