开发者

Cannot connect to the ManagementScope via C#. Access denied

I'm trying to connect to the ManagementScope as follows:

ManagementScope scope = new ManagementScope( @"\\mydomain\root\RSOP\Computer"));
scope.Connect();

But an exception (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) is thrown if the current user is not a domain administrator. How can a simpl开发者_Python百科e domain user connect to this management scope?

Thanks.


try this.....

ConnectionOptions con = new ConnectionOptions();
                  con.Username = "Administrator";
                  con.Password = "Password";

ManagementScope scope = new ManagementScope(@"\\" + strIPAddress + @"\root\cimv2", con);
                scope.Connect();


Unfortunately you can't without elevating the domain user's privileges.

If you were writing a deployable application you could sandbox WMI access in a Windows Service hosting a WCF or Remoting application.

This service would be configured to run under an account with sufficient rights to access WMI. Your WCF/Remoting application would expose whatever functionality or data you need access to via wrapper methods. These methods could be called by client applications without elevated rights.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜