views:

1053

answers:

5

I have a windows service running which moves files from a watched folder (IO.FileSystemWacher) to a UNC share on a network.

The network share is secured, but the share has full control for the Service user; despite this I get problems with the file path not being found.

I intend to impersonate the service (current) user, but am not sure if this is the right way to go about this.

Ideas?

A: 

Try granting the machine account of the computer that is running the service access to the share. Alternatively, run the service under a domain account (that obviously has access to the share)

Brendan Green
I don't have those privileges. I'm working on a customer site, and this is one of only 3 machines I can access directly.I can access our web servers, and our database instances, but I am unable to access other machines.
Hooloovoo
+2  A: 

Firstly check the path is what you think it is.

To check permissions you can run Internet Explorer under the identity of the service account (do runas) and then put the path in the URL box to check the service account can access the path.

RichardOD
I can map to the drive using if I connect as the service account. The share exists, I just can't seem to access the file.
Hooloovoo
A: 

Check these:

  • Is your Service user a domain account? (local account won't do)
  • Does the Service user has NTFS write permission on the UNC share? (share-level permission is not enough, must also have NTFS permission)
Vizu
You could very well be onto something with the NTFS and Share permissions being different. They are, and there is now a case raised with the vendors infrastructure team.Thanks
Hooloovoo
A: 

How are you accessing the share? Isn't it by any chance the mounted directory? So lets say \server1\direcotry1 is mounted to z:\directory1 or something like that. If it is so, you have to make sure that the service user "sees" the mounted directory. Or go with standard UNC path (with double \).

Marcin K
The share is being accessed using a standard UNC path.
Hooloovoo
A: 

Does the FileSystemWatcher always fail to connect to the UNC share or does it happen after the watcher has been running?

I have seen that if you reboot a machine where the watched folder resides, the FileSystemWatcher running on another machine will no longer see the change events. To work around this, you will need to restart the watcher. I believe you can use the EnableRaisingEvents property to do this.

Tim
Tim, if you read the question carefully he doesn't specify that a FileWatcher is looking at a UNC share. What are you talking about is a real issue with the FileSystemWatcher though. Have you seen this: http://www.codeproject.com/KB/vb/AdvancedFileSystemWatcher.aspx
RichardOD
One of the first things I checked when I started this development was that I could watch a UNC share with the filewatcher. The files in the watched folder are moved so they can be processed.
Hooloovoo