WMI for Remote System
-
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
-
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
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
-
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
Thanks for ur reply. yes i have given the Administrator username and password of the remote system. any other problem?? thank u by joe
-
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
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.....
-
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.....
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