Is a Windows Service not allowed file access to a network share?

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
I'm working on a system that has a several computers that run an alerting system. There are 2 "Host" machines that have no user interface, and one "Admin" station that has an Administrator's application for configuring and reporting. They are on a simple local network, just the 3 machines, no wider access.

We do a certain amount of communication between them, using UDP and MessageQueueing and also in one instance a VB.Net Windows Forms application on the Admin station, that has a button that a user can click that will write a new ini file for the system and send it to a network share on the Hosts, named "DataShare". It is simple enough, just using File.Delete and File.Copy, with the normal syntax -- File.Copy("C:\IniFileFolder\Configuration.ini", "\\HostA\DataShare\Configuration.ini"). It's been working for a long time.

There is also a Windows Service application written in VB.Net, running on the Admin station. It runs as a Service and receives and processes stuff coming in on the MessageQueue. We want to use it as a means of deleting old, out-of-date log files on the Hosts. There are many logs kept, each one starts a new dated log file once per day, and we figure we will delete logs older than 10 days. I wrote a simple method that works just fine, but I did it as a development version in a Forms application first, since that's easier to debug. I copied the method's code into the Service, built it, installed it, and now I find that it throws an Exception

System.UnauthorizedAccessException: Access to the path "\\HostA\DataShare\Configuration.ini" is denied.

The exact same code, it works in the Forms version, fails in the Service version.

Is there some security aspect to Windows XP Pro that does not allow file access to a Service running on another machine?
 

tkdkid

Senior member
Oct 13, 2000
956
0
0
It works as a form, so it's probably not a .net security setting that's causing the exception. I would guess that the service is running as the local 'system' user, which is a local account that doesn't have access to the network share. To get this to work, the service would need to log in and run using the credentials of a network user.
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
that's what I got on another forum. I tried it and it worked. I don't know much about security and logons and access and networking.
 

oog

Golden Member
Feb 14, 2002
1,721
0
0
Most services run as the local SYSTEM account, which does not have network access. Run the service as a different user if you want to get around this.