WMI security via ASP.NET app

G

groups.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
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top