SCCM SDK call InvokeMethod error "Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)" RRS feed

  • 问题

  • i had run a program that remote to get the process name of SCCM server. It is successful to get the process name. but i want to try to call RequestMachinePolicy "invokemethod("RequestMachinePolicy", new object[]{2});. But it is fail and the error message is "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))". I had search some solution by WMI security problem and follow their instruction but also fail. Does anyone experience this problem?

    i had captured my coding for reference:

                    ManagementScope scope = new ManagementScope("\\\\" + ConnProperty.SERVER + "\\root\\CCM", oConn);
                    Console.WriteLine(scope.IsConnected);  <--- it is output "True"

                    ManagementClass cls = new ManagementClass(scope.Path.Path, "SMS_Client", null);

                    cls.InvokeMethod("RequestMachinePolicy", new object[] { 0 });

    it is the exception errror is below:

    System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))   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.ManagementObject.Initialize(Boolean getObject)
       at System.Management.ManagementObject.InvokeMethod(String methodName, Object[
    ] args)
       at ConsoleApplication2.UITesting.testManageScope() in C:\Documents and Settings\Administrator\My Documents\CMTesting\ConsoleApplication2\ConsoleApplication2\UITesting.cs:line 678

    Does anyone have a suggestion for this problem? Thanks

    2010年4月30日 7:55


  • You may try to add your current user to DCOM group of remote machine.

    Configuration Manager China R&D Blog:
    2010年4月30日 12:09