Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. WMI for Remote System

WMI for Remote System

Scheduled Pinned Locked Moved C#
helpcsharpsecurityquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Joe Rozario
    wrote on last edited by
    #1

    Dear friends, I have Created a windows Service in .net 2005 to find the WMI Classes that are available in a system. When I invoke this windows service through a web site I could get all the WMI Classes available in my system. But it throws an error “Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) “ Like this for the remote System. Note: I have given the correct User name and Password. And this same code works fine in windows application,console application and web site for the remote system and local system.. This is the Code: private string[] GetClassesList(string sIPAddress, string sWMINameSpace, string sUserName, string sPassword, bool bRemoteSystem) { int queryClassCount = 0; string[] aClassList = null; ConnectionOptions cnnOptions = new ConnectionOptions(); ManagementObjectCollection objClassColl = null; cnnOptions.Username = sUserName; cnnOptions.Password = sPassword; cnnOptions.Authentication = AuthenticationLevel.Packet; ManagementObjectSearcher searcher = null; try { if (bRemoteSystem) { searcher = new ManagementObjectSearcher(new ManagementScope(@"\\" + sIPAddress + @"\" + sWMINameSpace, cnnOptions), new WqlObjectQuery("select * from meta_class"), null); } else { searcher = new ManagementObjectSearcher(new ManagementScope(sWMINameSpace), new WqlObjectQuery("select * from meta_class"), null); } objClassColl = searcher.Get(); //aClassList = new string[objClassColl.Count+1]; } catch (Exception me) { MessageBox.Show(me.Message); } Friends, Is there any problem in my code? Any idea’s or Link Help me Thank u. by Joe

    V A 2 Replies Last reply
    0
    • J Joe Rozario

      Dear friends, I have Created a windows Service in .net 2005 to find the WMI Classes that are available in a system. When I invoke this windows service through a web site I could get all the WMI Classes available in my system. But it throws an error “Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) “ Like this for the remote System. Note: I have given the correct User name and Password. And this same code works fine in windows application,console application and web site for the remote system and local system.. This is the Code: private string[] GetClassesList(string sIPAddress, string sWMINameSpace, string sUserName, string sPassword, bool bRemoteSystem) { int queryClassCount = 0; string[] aClassList = null; ConnectionOptions cnnOptions = new ConnectionOptions(); ManagementObjectCollection objClassColl = null; cnnOptions.Username = sUserName; cnnOptions.Password = sPassword; cnnOptions.Authentication = AuthenticationLevel.Packet; ManagementObjectSearcher searcher = null; try { if (bRemoteSystem) { searcher = new ManagementObjectSearcher(new ManagementScope(@"\\" + sIPAddress + @"\" + sWMINameSpace, cnnOptions), new WqlObjectQuery("select * from meta_class"), null); } else { searcher = new ManagementObjectSearcher(new ManagementScope(sWMINameSpace), new WqlObjectQuery("select * from meta_class"), null); } objClassColl = searcher.Get(); //aClassList = new string[objClassColl.Count+1]; } catch (Exception me) { MessageBox.Show(me.Message); } Friends, Is there any problem in my code? Any idea’s or Link Help me Thank u. by Joe

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      The account which runs this service must have sufficient privileges on the system that is being connected to.

      Vasudevan Deepak Kumar Personal Homepage Tech Gossips

      J 1 Reply Last reply
      0
      • V Vasudevan Deepak Kumar

        The account which runs this service must have sufficient privileges on the system that is being connected to.

        Vasudevan Deepak Kumar Personal Homepage Tech Gossips

        J Offline
        J Offline
        Joe Rozario
        wrote on last edited by
        #3

        Thanks for ur reply. yes i have given the Administrator username and password of the remote system. any other problem?? thank u by joe

        1 Reply Last reply
        0
        • J Joe Rozario

          Dear friends, I have Created a windows Service in .net 2005 to find the WMI Classes that are available in a system. When I invoke this windows service through a web site I could get all the WMI Classes available in my system. But it throws an error “Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) “ Like this for the remote System. Note: I have given the correct User name and Password. And this same code works fine in windows application,console application and web site for the remote system and local system.. This is the Code: private string[] GetClassesList(string sIPAddress, string sWMINameSpace, string sUserName, string sPassword, bool bRemoteSystem) { int queryClassCount = 0; string[] aClassList = null; ConnectionOptions cnnOptions = new ConnectionOptions(); ManagementObjectCollection objClassColl = null; cnnOptions.Username = sUserName; cnnOptions.Password = sPassword; cnnOptions.Authentication = AuthenticationLevel.Packet; ManagementObjectSearcher searcher = null; try { if (bRemoteSystem) { searcher = new ManagementObjectSearcher(new ManagementScope(@"\\" + sIPAddress + @"\" + sWMINameSpace, cnnOptions), new WqlObjectQuery("select * from meta_class"), null); } else { searcher = new ManagementObjectSearcher(new ManagementScope(sWMINameSpace), new WqlObjectQuery("select * from meta_class"), null); } objClassColl = searcher.Get(); //aClassList = new string[objClassColl.Count+1]; } catch (Exception me) { MessageBox.Show(me.Message); } Friends, Is there any problem in my code? Any idea’s or Link Help me Thank u. by Joe

          A Offline
          A Offline
          Amit Kumar G
          wrote on last edited by
          #4

          As this forum is quite old but in case you need any help, let me know. We completed medium size internet projects where i troubleshoot all this.....

          J 1 Reply Last reply
          0
          • A Amit Kumar G

            As this forum is quite old but in case you need any help, let me know. We completed medium size internet projects where i troubleshoot all this.....

            J Offline
            J Offline
            Joe Rozario
            wrote on last edited by
            #5

            Hai Thanks for u r reply. plz give solution for this problem. I've given administrator username and password. it works fine for remote system when i execute as windows exe but when i create as windows service it throws "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" error. Thank u by joe

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups