Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First thing I want to tell you is how I found this solution. This is probably more important than the answer because file permissions are hard to get correct.</p> <p>First thing I did was set the permissions I wanted using the Windows dialogs and checkboxes. I added a rule for "Everyone" and ticked all boxes except "Full Control".</p> <p>Then I wrote this C# code to tell me exactly what parameters I need to duplicate the Windows settings:</p> <pre><code>string path = @"C:\Users\you\Desktop\perms"; // path to directory whose settings you have already correctly configured DirectorySecurity sec = Directory.GetAccessControl(path); foreach (FileSystemAccessRule acr in sec.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount))) { Console.WriteLine("{0} | {1} | {2} | {3} | {4}", acr.IdentityReference.Value, acr.FileSystemRights, acr.InheritanceFlags, acr.PropagationFlags, acr.AccessControlType); } </code></pre> <p>This gave me this line of output:</p> <pre><code>Everyone | Modify, Synchronize | ContainerInherit, ObjectInherit | None | Allow </code></pre> <p>So the solution is simple (yet hard to get right if you don't know what to look for!):</p> <pre><code>DirectorySecurity sec = Directory.GetAccessControl(path); // Using this instead of the "Everyone" string means we work on non-English systems. SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null); sec.AddAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.Modify | FileSystemRights.Synchronize, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow)); Directory.SetAccessControl(path, sec); </code></pre> <p>This will make the checkboxes on the Windows security dialog match what you have already set for your test directory.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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