473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

UnauthorizedAccessException in service. Confused

I'm testing my first service and I'm receiving the above exception whenever
I attempt to open some files for writing. Reading is fine.
The files are on the same directory as my service application and hold
application configuration settings.
On the other hand, a log file that I write to the c:\temp directory causes
no problems and opens every time.
The account the serviceinstaller was set up to use was "LocalService".

I have just changed the account to "LocalSystem" and I've stopped getting
the problems.

I need to be able to do the following from my service :
1) Read/write configuration files in the same directory as the application
2) Read/write a log file in a directory selected by the user.
3) Talk to a remote SOAP server
4) I think interop services create cs files at runtime to create objects to
talk to a dynamically loaded unmanaged dll. I noticed some errors regarding
this in one of my log files on a single occasion.

Will LocalSystem be ample to do this task without errors please?
Why would writing to my log file work ok and yet not the other ones when I
was using the LocalSystem account?

thanks

Nov 17 '05 #1
5 2776
Hi,

Are you trying to write the config file, cause you can't

if you want to read/write config files use another file than
servicename.exe.config

Otherwise I don't see why you would get any error running it under
LocalSystem, in fact IIRC almost all services log in as LocalSystem
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Claire" <as*******@ntlworld.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
I'm testing my first service and I'm receiving the above exception
whenever I attempt to open some files for writing. Reading is fine.
The files are on the same directory as my service application and hold
application configuration settings.
On the other hand, a log file that I write to the c:\temp directory causes
no problems and opens every time.
The account the serviceinstaller was set up to use was "LocalService".

I have just changed the account to "LocalSystem" and I've stopped getting
the problems.

I need to be able to do the following from my service :
1) Read/write configuration files in the same directory as the application
2) Read/write a log file in a directory selected by the user.
3) Talk to a remote SOAP server
4) I think interop services create cs files at runtime to create objects
to talk to a dynamically loaded unmanaged dll. I noticed some errors
regarding this in one of my log files on a single occasion.

Will LocalSystem be ample to do this task without errors please?
Why would writing to my log file work ok and yet not the other ones when I
was using the LocalSystem account?

thanks

Nov 17 '05 #2
Thanks Ignacio
Nov 17 '05 #3

"Claire" <as*******@ntlworld.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
I'm testing my first service and I'm receiving the above exception
whenever I attempt to open some files for writing. Reading is fine.
The files are on the same directory as my service application and hold
application configuration settings.
On the other hand, a log file that I write to the c:\temp directory causes
no problems and opens every time.
The account the serviceinstaller was set up to use was "LocalService".

I have just changed the account to "LocalSystem" and I've stopped getting
the problems.

I need to be able to do the following from my service :
1) Read/write configuration files in the same directory as the application
2) Read/write a log file in a directory selected by the user.
3) Talk to a remote SOAP server
4) I think interop services create cs files at runtime to create objects
to talk to a dynamically loaded unmanaged dll. I noticed some errors
regarding this in one of my log files on a single occasion.

Will LocalSystem be ample to do this task without errors please?
Why would writing to my log file work ok and yet not the other ones when I
was using the LocalSystem account?

thanks


You should grant the "NETWORK SERVICE" account write access privileges to
the folders.
Don't run your services as SYSTEM.

Willy.

Nov 17 '05 #4
> You should grant the "NETWORK SERVICE" account write access privileges to
the folders.
Don't run your services as SYSTEM.

Willy.


Why not please Willy?
Nov 17 '05 #5

"Claire" <as*******@ntlworld.com> wrote in message
news:O$**************@TK2MSFTNGP10.phx.gbl...
You should grant the "NETWORK SERVICE" account write access privileges to
the folders.
Don't run your services as SYSTEM.

Willy.


Why not please Willy?


Claire,

Because you don't need the high (dangerous) privileges the SYSTEM account
has.
This is all about writing secure code, you should always try to write
applications that execute with the least privileges to get the job done.
There are only very few application that need SYSTEM privileges and these
aren't written in managed code anyway.
In your case the service doesn't need the SYSTEM account's privileges to
access the file system, you only have to grant "NETWORK SERVICE" write
access privileges to your application folders.

Willy.

Nov 17 '05 #6

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

Similar topics

0
by: Jessica | last post by:
I have a .Net 1.0 web service that uses a .Net 1.1 assembly to create users, change users' passwords, validate users, and remove users from an LDAP server. The 1.1 code uses the DirectoryServices...
3
by: R Warford | last post by:
Visual Studio throws an UnauthorizedAccessException when I attempt to debug my ASP.NET application. The error message refers to what appears to be a temporary DLL created by Visual Studio. The...
0
by: Efi | last post by:
Hi, We have a simple 3 tier application which its core application is VC++ 6.0 ATL COM running as a server application in the COM+. An asp pipe is in charge of handling the requests and passes it...
7
by: Peter Afonin | last post by:
Hello, I'm using this code to access a network share from an asp.net page: Dim dir As DirectoryInfo = New DirectoryInfo("\\10.0.0.150\FormLib\") Dim files() As FileInfo = dir.GetFiles("*.eps")...
4
by: Bruce | last post by:
I am developing an ASP.NET web service application. It works fine on my WinXP Prof development machine. But when I send it to a Windows Server 2003 system I get the following error (attached...
3
by: Bruce | last post by:
I need to read a file within a web service, but am having (apparently) permissions problems. Code snip is posted below. When I attempt to open a filestream to read a file, I get an...
0
by: masago | last post by:
Hi....how are you ?? they can help me to solve this problem ?? Access to the path = "c:\windows\microsoft.net\framework\v1.1.4322\Temporary ASP.NET = Files\reports\06639073\bbab30a7" is...
5
by: Kristoffer Persson | last post by:
Hi all! I'm trying to use a named EventWaitHandle to signal events between processes that run on the same computer. One of them is a service running as SYSTEM and the other one is a normal user....
3
by: sean | last post by:
hi, I have a problem making window service. My service tries to access local files and network files. when I let it strated, unauthorizedaccessexception is occurred! I guess my window service do...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.