P
Pete
Hello,
I have an ASP.NET application which is querying the status of a Win32
service using WMI via ManagementObjectSearcher object. The query is
"select state from win32_service where name='MyService'". My website
is impersonating the IIS anonymous user, using a domain user. I have
given my user the appropriate WMI security rights, and my code works
fine when run from a cmd prompt running as my domain user. However,
when I run via my ASP.NET app I get:
[ManagementException: Generic failure ]
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus
errorCode) +167
System.Management.ManagementObjectEnumerator.MoveNext() +403
It also works fine if I add my domain user to the local Administrators
group.
I guess there is something I'm missing with regard to the ASP.NET
security, can anyone point me in the right direction? Thanks for your
help.
The code is below.
ConnectionOptions co = new ConnectionOptions();
co.Authentication = AuthenticationLevel.Packet;
ManagementScope oScope = new ManagementScope("\\\\" + server +
"\\root\\cimv2", co);
WqlObjectQuery oQuery = new WqlObjectQuery(QueryString);
ManagementObjectSearcher search = new
ManagementObjectSearcher(oScope,oQuery);
foreach(ManagementObject manobj in search.Get())
{
//do stuff
}
I have an ASP.NET application which is querying the status of a Win32
service using WMI via ManagementObjectSearcher object. The query is
"select state from win32_service where name='MyService'". My website
is impersonating the IIS anonymous user, using a domain user. I have
given my user the appropriate WMI security rights, and my code works
fine when run from a cmd prompt running as my domain user. However,
when I run via my ASP.NET app I get:
[ManagementException: Generic failure ]
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus
errorCode) +167
System.Management.ManagementObjectEnumerator.MoveNext() +403
It also works fine if I add my domain user to the local Administrators
group.
I guess there is something I'm missing with regard to the ASP.NET
security, can anyone point me in the right direction? Thanks for your
help.
The code is below.
ConnectionOptions co = new ConnectionOptions();
co.Authentication = AuthenticationLevel.Packet;
ManagementScope oScope = new ManagementScope("\\\\" + server +
"\\root\\cimv2", co);
WqlObjectQuery oQuery = new WqlObjectQuery(QueryString);
ManagementObjectSearcher search = new
ManagementObjectSearcher(oScope,oQuery);
foreach(ManagementObject manobj in search.Get())
{
//do stuff
}