Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-28-2008, 12:42 AM   PM User | #1
M_Dave
New to the CF scene

 
Join Date: Mar 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
M_Dave is an unknown quantity at this point
System.IO.FileSystemWatcher - permissions required for watching

Hi - looking for help answering a question that's bugging me. I have developed a Windows service that watches directories using the System.IO.FileSystemWatcher object. The directory to watch is set via the config file for the service. The Windows service runs under an account that's a member of the Administrators group on the machine it's installed to.

The problem is getting the FileSystemWatcher to watch a directory that's on another machine in the same domain. When the directory to watch is on another machine, the Windows service throws an invalid directory Exception. This is because the service doesn't have the required permissions on the other machine.

I thought there might be 2 ways to solve this.
1. Make the account the Windows service runs under a member of the Administrators group on the other machine. OR
2. Give the account the Windows service runs full control over the directory on the other machine.

The first solution works (making the account an Administrator). The second, which is my preferred solution because it involves a more limited set of permissions, doesn't. I can't understand why not. Why wouldn't you be able to have a FileSystemWatcher watch a directory on another machine that you have full control over?

Can anyone shed some light on this?
M_Dave is offline   Reply With Quote
Old 09-25-2008, 07:56 PM   PM User | #2
ess
Regular Coder

 
Join Date: Oct 2006
Location: United Kingdom
Posts: 865
Thanks: 7
Thanked 29 Times in 28 Posts
ess will become famous soon enough
Make sure that the account that the service runs under is capable of reading, writing and accessing that directory. In other words, check the effective permissions

1- Right mouse click on the folder...and select Security & sharing
2- Select the security tab and click on the advanced button
3- Select the Effective Permissions tab
4- Click on Select and enter the user name

You will be able to see all the effective permissions for that user.

You will need to ensure that the directory in question does not inherit from its parent directory....and that permissions for that user applies to all sub-directories.

It might be a good idea to login under that user...and see if it is possible to navigate the directory, alter its contents...etc.

Cheers
~E
ess is offline   Reply With Quote
Reply

Bookmarks

Tags
file watching, filesystemwatcher, network permissions, permissions, system monitoring

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:24 PM.


Advertisement
Log in to turn off these ads.