473,466 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to protect a VB.net windows service?

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!
Nov 21 '05 #1
3 2179
I would suggest that you take a look at the classes dealing with user
authentication. There should be a way of check to see if the currently
logged in user is an administrator.

Richard Rosenheim
"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!

Nov 21 '05 #2
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!

Nov 21 '05 #3
Well, one thing I am doing, is capturing the username when someone logs in
(In a seperate helper application). This helper application then passes the
username into my service. I suppose I could also pass/lookup the
credentials at this point.

Currently I am using a TCP port to do this... wish there were a simpler way
for this. But it seems to be working fine.

So, if I know the credentials of a user as they log in, its sounding like I
could update the "CanStop" flag of the service?

Thanks!

"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!

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Frank Millman | last post by:
Hi all I am writing a multi-user accounting/business system. Data is stored in a database (PostgreSQL on Linux, SQL Server on Windows). I have written a Python program to run on the client,...
9
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service...
15
by: Fady Anwar | last post by:
Hi while browsing the net i noticed that there is sites publishing some software that claim that it can decompile .net applications i didn't bleave it in fact but after trying it i was surprised...
1
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm...
12
by: chinkuang | last post by:
Hi Everyone: I have a question here: I used a startup object to protect my application - whenever PC starts up, I will check the setting of my application like registry, program files and so on,...
5
by: alekatz | last post by:
Hi, I developed an aplication for an autoservice Kiosk, witch will be rented to customers. I want to lock a folder where sensitive files will reside, something like a password. Encryption will not...
4
by: tshad | last post by:
What would be a good way to check programmatically whether a service was running? We have a service that dies periodically and I need to check to see if this service is running. I know how to...
22
by: teejayem | last post by:
Hi, I am new to programming with databases and was wanting some help. Is there any way to password protect an access database and access sent sql commands to it via vb.net code? Any help...
3
by: Sin Jeong-hun | last post by:
It seems like the Protect() uses the Windows accout information to encrypt data. If I know the user name and the password, can I decrypt it on another PC? If it is not, how about the exported key?...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.