I am looking for ideas to gather more information from the system about why a remote WMI call is failing.
The detailed steps in Which permissions/rights does a user need to have WMI access on remote machines? were helpful, but either I've accidentally missed something or there is something more that needs to be configured for my environment.
I am seeing the following exception when I run the .NET 4.0 C# code (snippet below):
System.UnauthorizedAccessException occurred Message=Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Source=System.Management StackTrace: at System.Management.ThreadDispatch.Start() at System.Management.ManagementScope.Initialize() at System.Management.ManagementScope.Connect() at MyNamespace.MyClass.GetWmiInfo() in...
This is the code where the error occurs. The exception is thrown on the call to Connect().
var scope = new ManagementScope("\\\\HOSTNAME\\root\\cimv2")
{
Options =
{
Impersonation = ImpersonationLevel.Impersonate,
Password = "password",
Username = "domain\\username"
}
};
scope.Connect();
The code is being run on a Windows 7 computer, and the target of the WMI connection is a Windows XP computer. Note: I see a similar problem if I reverse the two roles.
I don't see any errors logged in the target computer's security log.
If I add the user whose credentials are being used to the Administrators group on the target computer, the call to Connect()
succeeds, so the problem does seem to really be due to a privilege or access which is not yet granted.
Normally when I encounter access-denied errors I would be able to find an entry in a log that gives more detail, or would be able to run regmon or filemon to capture some useful information. But with this WMI / DCOM error, I don't know where else to look for more information.
Any suggestions much appreciated!
Update: I tested using WBEMTest.exe and found that access is also denied, unless I run as an administrator. I am trying to continue working with this tool to further isolate the problem.