Update: I originally posted that the "in" directory was on C: . It is actually on E: . D: and E: are volumes on a RAID. I wouldn't expect that to make a difference, but if I knew what was going on, I wouldn't have had to ask the question.
I am having a problem with the ACL permissions of directories which must be controlled by both web services and local users. This is my first project that involves directory security and ACLs, so I am concerned that I am thinking about this all wrong. I am open to answers that provide a point-fix, as well as those that would suggest an overhaul of my security model.
I am working on a Windows Server 2012 R2 web service that captures data from a number of users (Nodes) and then processes it. I have per Node directories (e.g. E:\in\node1, E:\in\node2, etc.) to hold the incoming data, and then I use a C# console app that I run as a non-administrative local user (LocalUser) to move the files to a larger volume with a deeper directory structure that reflects classification done by the console app.
Initially, I would create the directories for each Node as LocalUser, but in the interests of manageability, I made a web service (POST Handler) to create the Node directories as each one is provisioned and configured.
I now have a file system in which some directories were created by LocalUser and some by DefaultAppPool via the web service. Both types of directories receive files as expected. When I run my console app as LocalUser, everything works fine for the LocalUser-created directories, but I get an UnauthorizedAccessException when I try to File.Move() from a web-created Node directory to a web-created Classification directory. When I look at the ACLs, I see that problem is that the Creator (and account with Full Control) is different than the account running the console app. Also, the ACL page says that E:\in\node2 inherited from E: , not E:\in .
The whole point of the web-provisioning was to automate the system, so I do not want to have to touch all of the new directories to add LocalUser (or a group containing LocalUser). I also want the system to work when other authenticated users attempt to run the console app (e.g. LocalUser2 who never created any directories anywhere).
It seems that the two opportunities that I would have to fix this are 1) when the web service creates the directories, or 2) when LocalUser runs the script. Unfortunately, I am concerned that neither account (DefaultAppPool, LocalUser) have the permissions to grant (in case 1)) or seize (in case 2)) Full Control of the directories in question.
Eventually, I plan to run the console app from the web services, and that would make everything run as DefaultAppPool, but during development, and as a manual maintenance operation, I would like to be able to run the console app on demand as LocalUser or LocalUser2. I was thinking it might be possible to make some sort of "shim" that impersonated DefaultAppPool while running the console app, but as far as I can tell, the only way to do such impersonation is by having the web-service do it.
In summary, how can I have a system in which web services create directories that are then controllable by users in a particular group?