473,480 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Configure framework security to start/stop service

Don't answer this unless you know what you are talking about.

I want to use ServiceController in my code to start and stop a Windows
Service.
I do not want to use <impersonate> in my config file.
This means I must use the Framework Configuration to create Code Group and
Permissions.

I've attempted to create a new Code Group and have tried several different
pieces of
"evidence", but no matter what I have tried, I continue to get "access
denied".

Has anyone ever really done this before...the web is empty to this scenario
:-(

My code is:

[assembly:ServiceControllerPermissionAttribute(Secu rityAction.RequestMinimum
, PermissionAccess=ServiceControllerPermissionAccess .Control)]
..
..
..
ServiceController sc = new ServiceController("myservicename");
sc.Start();
Nov 18 '05 #1
2 1662
your mixing .net code security with OS security. the .net security
attributes control what evidence a routine needs to be called from another.
this has nothing to do with OS permission need to perform an OS call.

to call the SystemController, the calling thread needs to running as an NT
account (security token) that has enough permissions. unless you run asp.net
as system (not recommended), the only solution is to impersonate a token
that has the required permissions before making the call.

-- bruce (sqlwork.com)
"Amil" <am********@hotmail.com> wrote in message
news:#H**************@TK2MSFTNGP10.phx.gbl...
Don't answer this unless you know what you are talking about.

I want to use ServiceController in my code to start and stop a Windows
Service.
I do not want to use <impersonate> in my config file.
This means I must use the Framework Configuration to create Code Group and
Permissions.

I've attempted to create a new Code Group and have tried several different
pieces of
"evidence", but no matter what I have tried, I continue to get "access
denied".

Has anyone ever really done this before...the web is empty to this scenario :-(

My code is:

[assembly:ServiceControllerPermissionAttribute(Secu rityAction.RequestMinimum , PermissionAccess=ServiceControllerPermissionAccess .Control)]
.
.
.
ServiceController sc = new ServiceController("myservicename");
sc.Start();

Nov 18 '05 #2
I added this to my root web.config. Notice I used the path so that not all
web stuff did the impersonation.

<location path="mypath">
<system.web>
<identity impersonate="true" userName="myusername"
password="mypassword"/>
</system.web>
</location>

Thanks for the help.
"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
your mixing .net code security with OS security. the .net security
attributes control what evidence a routine needs to be called from another. this has nothing to do with OS permission need to perform an OS call.

to call the SystemController, the calling thread needs to running as an NT
account (security token) that has enough permissions. unless you run asp.net as system (not recommended), the only solution is to impersonate a token
that has the required permissions before making the call.

-- bruce (sqlwork.com)
"Amil" <am********@hotmail.com> wrote in message
news:#H**************@TK2MSFTNGP10.phx.gbl...
Don't answer this unless you know what you are talking about.

I want to use ServiceController in my code to start and stop a Windows
Service.
I do not want to use <impersonate> in my config file.
This means I must use the Framework Configuration to create Code Group and Permissions.

I've attempted to create a new Code Group and have tried several different pieces of
"evidence", but no matter what I have tried, I continue to get "access
denied".

Has anyone ever really done this before...the web is empty to this

scenario
:-(

My code is:

[assembly:ServiceControllerPermissionAttribute(Secu rityAction.RequestMinimum
, PermissionAccess=ServiceControllerPermissionAccess .Control)]
.
.
.
ServiceController sc = new ServiceController("myservicename");
sc.Start();


Nov 18 '05 #3

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

Similar topics

0
2726
by: Per Bergland | last post by:
After many woes, I finally managed to get a stack dump of my System Service (written in C#) that insists on crashing when launched at system boot time (see below on how to get this dump - I...
6
2061
by: Joseph Geretz | last post by:
I recently upgraded my server to Windows 2003. The first thing I noticed is that my sample WebService pages no longer worked. The Invoke test button is missing. This is addresed by the following KB...
9
3181
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My...
2
7193
by: MA | last post by:
Hi all! I have developed a webservice that writeing and reading files in different folders. I need to be able to start and stop this service by using a web interface (start and stop button)....
3
1169
by: Benj | last post by:
I am looking for a way to cleanly stop my service in the event of an error. Within the worker thread, if an unrecoverable error is caught, I would like to stop my service. Exiting the worker...
7
7209
by: shai | last post by:
I am working at .net 1.1, writing in c#. I have windows service with a COM object. Every unexpected time The COM object throw an error that make my service get stuck (do not respond). I can catch...
17
1937
by: HartsVideo | last post by:
Hi, No one seems to know the answers to these questions or they're just not telling. I downloaded and installed .NET Framework 2.0 and along with it came ASP.NET. .NET Framework 2.0 wrecked...
4
21670
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
13
1863
by: José Joye | last post by:
Hello, What is the best way to stop a remoting server (Singleton SAO) that has been started with RemotingConfiguration.Configure(). For sure, I want to do this without quitting the application...
0
7037
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
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7032
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,...
1
6730
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4767
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4471
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
2990
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
1294
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 ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.