title: Allowing administrators to modify user's settings from within my program -- what's my best option?
body: <p>I've been working on making my app easier to use for administrators. One of the things I'd really like to do is allow admins to modify other user's settings from within the program -- while still making it possible for regular ol' users to modify their own settings, as my application isn't necessarily only for administrators who want to force users to use specific settings.</p>
  
  <p>I thought of two possible ways of doing this:</p>
  
  <blockquote><b>1)</b> Move the user setting file path from where it is now (CLSID_APPDATA, commonly <b>Documents and Settings\<i>Username</i></b>) to a world-accessible path (CLSID_COMMON_APPDATA , commonly <b>Documents and Settings\All Users</b>). Then, save each user's settings to a unique file for the user (probably having a name which equals that of the user's textual SID), so the folder looks something like:<br><br>
      C:\Documents and Settings\All Users\My Company\My Program\settings\123-abc-456-def.settings<br>
      C:\Documents and Settings\All Users\My Company\My Program\settings\234-bcd-477-xyz.settings<br>
      C:\Documents and Settings\All Users\My Company\My Program\settings\946-hdc-743-ddd.settings
  <br><br>
  <b>Pros:</b><br><br><ul><li>This allows an admin to see and directly modify any user's settings, because the COMMON_APPDATA path is the same for all users. This is how I'd really like it to be -- it's the most straightforward -- but there's a major con:</li></ul>
  
  <b>Cons:</b><br><br><ul><li>Permissions could be a problem. To allow regular users to save their settings, you'd have to allow users write access to the program's COMMON_APPDATA setting folder.<br><br>
  
  Of course, when the settings are saved and the setting file created on disk, you'd want to limit write access on the user's setting file to the user who the settings are for, and for admins, so that other limited user's can't modify them.<br><br>
  
  However, it could be that before a user has a chance to write their own settings from within the program, a savvy, malicious limited user creates a setting file for that specific user, without the knowledge of the user. If the limited user creates the file, that means they own the file... and then that user (who the settings are for) can't modify the settings anymore, unless an admin changes the permissions on the file.<br><br>
  An unlikely situation perhaps, but it still worries me.</li></ul>
  
  <b>2)</b> Instead of moving the setting file path to a globally-accessible path and modifying the user's setting file directly, have my app create and save an "override" file in the app's CLSID_COMMON_APPDATA folder, to allow the admin to override the user's settings.<br><br>
  
  When my app loads for that user (who's settings were "overridden") it'll detect this file and load it instead of the regular setting file, which is located in CLSID_APPDATA (<b>Documents and Settings\<i>Username</i></b>).
  <br><br>
  <b>Pros:</b><br><br><ul><li>Permissions are easy to deal with.<br><br>
  
  By default, for the <b>Documents and Settings\<i>Username</i></b> APPDATA folder, only admins and <i>Username</i> can access the files from within. So that in itself protects the user's own regular personal settings from other limited users.<br><br>
  
  To protect the "override" settings, my app can simply deny write access to the COMMON_APPDATA folder -- where the override file is written -- to all but administrators, and then that's that. These overriding settings will only be modifiable by admins.</li></ul>
  
  <b>Cons:</b><br><br><ul><li>This method is obviously more roundabout. If a user modifies his own regular personal settings, an admin won't see those changes -- the admin can only see the settings he's overriding the user's regular settings with (which he can force the user to use instead).<br><br>
  
  In some ways, this might be good, but... the fact that it's roundabout turns me off somewhat.</li></ul></blockquote>
  
  <p>I'm interested to hear what you guys think about this. Which is my best option? I'm personally leaning more towards #2, because while it's less straightforward, it seems to be more secure and isn't <em>so</em> roundabout where it'd be confusing for an admin.</p>
  
  <p>However, I'm also open to suggestions. Is there a superior option you think would work better?</p>
  
  <p><b>EDIT 7/6/09:</b> I should note that for option #2, the admin could not only override all user's settings with a single override file, but also override an individual user's settings with an override file specific to that user (just like with option #1, that file name would likely be that of the SID of the user who's settings are being overridden). Not sure if that was completely clear in the original post.</p>