I have a windows service that polls a user selected directory for new files.When a Network location is selected (a folder on a remote machine on the same network),i query the user for the username and password of the remote machine (user who has access to the folder),i validate the same and store it to the registry for the service.This approach works fine.(service runs as localmachine and uses impersonation code).
But there are some scenarios that im unaware of ..
1. Wireless HDDs /Storage devices that are directly connected to the network.Currently i use impersonation code to supply user credentials.In such scenarios will the drive be directly accessible to the service running as localmachine?
2. How to deal with Domain Users who has access to the Folder?
I'm using the following code to impersonate a user
https://stackoverflow.com/a/9213965/848968
UserImpersonation impersonator = new UserImpersonation();
impersonator.impersonateUser("username", "", "password"); //No Domain is required
What to do in case of domain users?
- Wireless HDDs /Storage devices that are directly connected to the network.Currently i use impersonation code to supply user credentials.In such scenarios will the drive be directly accessible to the service running as localmachine?
How is the drive connected to? If its SMB via UNC paths, that should be fine. When you get into mapped drives, those are not available to the windows service.
- How to deal with Domain Users who has access to the Folder?
impersonator.impersonateUser("username", "domain", "password");
You may also want to check out this answer for more impersonation information and sample code. There's a great library that wraps this up for you.