views:

429

answers:

2

Hi All,

We are using the ServiceController object to query if our Service is running or not. Our web application that is performing the query is using Impersonation for security/login.

System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController("myService");
return sc.Status

Using an Administrator account, the query is successful. Using a limited account (non-administrator), the query is failing with a message of "Service myService was not found on computer '.'"... BUT it is only failing in Windows Server 2003 and not in Windows XP.

I've Googled it and checked in MSDN. I didn't find anything related to the usage of ServiceController in Windows Server 2003.

Any ideas?

EDIT: If there is a way to query the service status without using the ServiceController that doesn't involve "security" privileges, that might work for us. We just need to get the status of the service.

UPDATE:

I created a simple console application that will print the status of the service. I used the "runas" command to run the application using both the Administrator and Non-Administrator account. It both worked in Windows Server 2003... Which means that this is an issue of the privilege not being properly passed to the ServiceController call in the web application? IIS security stuff perhaps?

Thanks!

A: 

I thought that web app-s are supposed to be run in a sandbox. Allowing access to the service running on local computer isn't really what you should do, because of security issues.

Maybe you could tell us what you want to do and there is another solution?

kubal5003
A: 

Would using WMI help you?

Chetan