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,con sole 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;
ConnectionOptio ns cnnOptions = new ConnectionOptio ns();
ManagementObjec tCollection objClassColl = null;
cnnOptions.User name = sUserName;
cnnOptions.Pass word = sPassword;
cnnOptions.Auth entication = AuthenticationL evel.Packet;
ManagementObjec tSearcher searcher = null;
try
{
if (bRemoteSystem)
{
searcher = new ManagementObjec tSearcher(new ManagementScope (@"\\" + sIPAddress + @"\" + sWMINameSpace, cnnOptions),
new WqlObjectQuery( "select * from meta_class"), null);
}
else
{
searcher = new ManagementObjec tSearcher(new ManagementScope (sWMINameSpace) ,
new WqlObjectQuery( "select * from meta_class"), null);
}
objClassColl = searcher.Get();
//aClassList = new string[objClassColl.Co unt+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
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,con sole 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;
ConnectionOptio ns cnnOptions = new ConnectionOptio ns();
ManagementObjec tCollection objClassColl = null;
cnnOptions.User name = sUserName;
cnnOptions.Pass word = sPassword;
cnnOptions.Auth entication = AuthenticationL evel.Packet;
ManagementObjec tSearcher searcher = null;
try
{
if (bRemoteSystem)
{
searcher = new ManagementObjec tSearcher(new ManagementScope (@"\\" + sIPAddress + @"\" + sWMINameSpace, cnnOptions),
new WqlObjectQuery( "select * from meta_class"), null);
}
else
{
searcher = new ManagementObjec tSearcher(new ManagementScope (sWMINameSpace) ,
new WqlObjectQuery( "select * from meta_class"), null);
}
objClassColl = searcher.Get();
//aClassList = new string[objClassColl.Co unt+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
Comment