Gregory,
I don't believe you can within the service itself.
Remember when you use the Services plug-in with in a MMC console (such as
Computer Management - Services and Applications - Services) or a
ServiceController object, you are actually talking to the SCM (Service
Control Manager). My understanding is that the SCM runs under a system
account with elevated authorities. The SCM then talks to your service which
is running under the account that you configured it to run under.
So the service itself only knows specifically what account it is, not the
originating request. Seeing as this originating request may be either a
local or remote request, performed in either a local desktop, remote
desktop, COM+, .NET Remoting, IIS, or other context. I not seeing any way to
know who actually made the request.
What you might (*might*) be able to do is use RegEdit to deauthorize (Deny)
normal users to the registry key that defines the service itself, however I
have not tried it. I'm not sure if I would try it, without further
research...
Asking this "down the hall" in one of the security or server newsgroups
might give a more definite answer.
Hope this helps
Jay
"gregory_may" <None> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I would like to prevent a VB.Net windows service from stopping by any user
who does not have Administrative privilges on the box.
Is this possible in the "OnStop" or "OnShutdown" areas of
System.ServiceProcess.ServiceBase?
It looks like there is a "CanStop" property refered to in this article:
http://msdn.microsoft.com/library/de...classtopic.asp
But I dont know how to turn CanStop off/on only if someone has Admin
privledges.
Any suggestions?
Thanks!