Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The user is probably inheriting additional rights to the folder through membership of a group such as <code>Everyone</code>, so setting an <strong>Allow</strong> rule simply allows him to do something he could already do.</p> <p>Example:</p> <pre> - Root [Allow: read/write (Everyone)] - ParentFolder [Allow: read/write (Everyone) - inherited from Root] - RestrictedFolder [Allow: read/write (Everyone) - inherited from Root] [Allow: read (Restricted User) - this has no effect!] </pre> <p>You probably want to set a <strong>Deny</strong> rule instead. This should ensure that the user is prevented from writing to or deleting the folder, regardless of inherited permissions or membership of groups which are allowed to write there.</p> <pre><code>DirectorySecurity ds = Directory.GetAccessControl(folderPath); FileSystemRights allExceptRead = FileSystemRights.FullControl &amp; ~FileSystemRights.ReadAndExecute; // Use AccessControlType.Deny instead of Allow. FileSystemAccessRule fsa = new FileSystemAccessRule(username, allExceptRead, AccessControlType.Deny); ds.AddAccessRule(fsa); Directory.SetAccessControl(folderPath, ds); </code></pre> <p>So afterwards, the hierarchy looks like this:</p> <pre> - Root [Allow: read/write (Everyone)] - ParentFolder [Allow: read/write (Everyone) - inherited from Root] - RestrictedFolder [Deny: write (Restricted User) - This overrides the inherited permission] [Allow: read/write (Everyone) - inherited from Root] </pre> <p>If there is a chance that the user is not already allowed to read the folder through inheritance or group membership, then you will have to add two access rules, one like you have already (to explicitly allow reading) and another like mine (to explicitly prevent anything but reading). Example hierarchy afterwards:</p> <pre> - Root [Allow: read/write (Everyone)] - ParentFolder [Allow: read/write (Everyone)] // Prevent ParentFolder's permissions from propagating to child [Prevent child folders from inheriting permissions] - RestrictedFolder [Deny: write (Restricted User)] // Note the "Everyone" permission is not inherited. // Without explicitly allowing read, the user can do nothing to this folder [Allow: read (Restricted User) - Explicitly allow reading] </pre> <hr> <h1>Update</h1> <p>According to <a href="http://technet.microsoft.com/en-us/library/cc787794%28WS.10%29.aspx" rel="nofollow">this link</a>, denying <code>Delete</code> permission on the folder itself is not enough. You also need to deny <code>Delete subfolders and files</code> on the folder's <em>parent</em> folder. So your folder hierarchy will have to look like this:</p> <pre> - Root [Allow: read/write (Everyone)] - ParentFolder [Deny: delete subfolders and files (Restricted User)] [Allow: read/write (Everyone) - inherited from Root] - RestrictedFolder [Deny: write (Restricted User) - This overrides the inherited permission] [Allow: read/write (Everyone) - inherited from Root] </pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload