Click here to Skip to main content
15,888,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi dukes,
i am running the application which uses WMI(acts as a WMI server) in VM. and i am trying to access this from the machine in another domain.
i have given the proper domain accounts,impersonate levels and other fields of WMI to connect remote machine.
in addition i am able to connect through the WMI tool (WBEMTEST)
when i am trying to connect through my code it is throwning this error


SetUp : System.UnauthorizedAccessException : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Server stack trace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Management.ManagementScope.InitializeGuts(Object o)
at System.Management.ManagementScope.Initialize()
at System.Management.ManagementScope.Connect()
at Integration.Og.Client..ctor(String NamespacePath, String UserName, String Pwd, DateTime syncDailySchedule) in Client.cs: line 252
at Integration.Og.Ogclient.<>c__DisplayClass2.<getinstance>b__0() in Ogclient.cs: line 101
at System.Lazy`1.CreateValue()

Exception rethrown at [0]:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Management.ManagementScope.InitializeGuts(Object o)
at System.Management.ManagementScope.Initialize()
at System.Management.ManagementScope.Connect()
at Integration.OG.Ogclient..ctor(String NamespacePath, String UserName, String onGuardPwd, DateTime syncDailySchedule) in OnGuardClient.cs: line 252
at Integration.Og.Ogclient.<>c__DisplayClass2.<getinstance>b__0() in Ogclient.cs: line 101
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at Integration.Og.Ogclient.GetInstance(String NamespacePath, String UserName, String Pwd, DateTime syncDailySchedule) in Ogclient.cs: line 112
at Integration.UnitTest.Og.OgclientTest.Init() in OgclientTest.cs: line 24

i have enabled the remote persmisions in the machine too.

kinldy help me out in over coming this.
Posted
Updated 21-May-13 22:50pm
v3
Comments
David_Wimbley 21-May-13 11:15am    
Can you post the code you are using/snippet that is causing the exception? Also, when you run this locally (or if you are able to)...does the app work on your local box?

I would start by debugging things locally then moving on to remotely, if it doesn't even work on your local then there is no point in trying to debug the remote aspect of it as well.
valiant123 22-May-13 2:47am    
SecurityEventWatcher = new ManagementEventWatcher(scope, queryE);
SecurityEventWatcher.Start();
here is the piece of code i am getting this error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900