none
Remote WMI Connection access is denied

    Question

  • hi

     

    i have a very bad error

    i use tow machines on win 7 and i tried this code

     

    anagementEventWatcher watcher;
                    EventArrivedEventHandler eventArrivedDele;
                    ConnectionOptions co = new ConnectionOptions();
                    co.Username = userName;
                    co.Password = pass;
                    //co.Authority = "ntlmdomain:192.168.1.17";
                    co.Impersonation = ImpersonationLevel.Impersonate;
                    co.EnablePrivileges = true;
                    System.Management.ManagementScope scope = new System.Management.ManagementScope("\\\\" + ipAddress + "\\root\\cimv2", co);
                    EventQuery query = new EventQuery(

                    @"SELECT * FROM __InstanceCreationEvent " +

                    @"WHERE TargetInstance ISA 'Win32_NTLogEvent' ");//+

                    //  @"AND TargetInstance.EventCode =" + eventCode +

                    //   @"AND TargetInstance.SourceName ='" + sourceName + "'");
                    watcher = new ManagementEventWatcher(scope, query);
                    watcher.Scope.Connect();
                    eventArrivedDele = new EventArrivedEventHandler(EventArrived_Handler);
                    watcher.EventArrived += eventArrivedDele;
                    watcher.Start();

     

    and this configurations:

    http://www.packettrap.com/network/Knowledge-Base/PacketTrap-MSP/WMI-Troubleshooting.aspx#_Toc239699682

    http://msdn.microsoft.com/en-us/library/aa393613%28v=VS.85%29.aspx

    http://msdn.microsoft.com/en-us/library/aa393266%28VS.85%29.aspx#allowing_users_access_to_a_specific_wmi_namespace

    and still have the same error access is denied

    the problem comes from the last line of code

     

     

    plz any help

    Wednesday, December 22, 2010 8:01 AM