Wednesday, 28 June 2017

Programmatically Adding Permissions to a Folder


24down voteaccepted
I'd suggest you use the Well Known SID list (see http://support.microsoft.com/kb/243330). Authenticated User is always SID: S-1-5-11. If you use that, it ought to be language agnostic (but I've not tested).
Create a SecurityIdentifier and use that instead:
var sid = new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null); 

Security.AddAccessRule(
   new FileSystemAccessRule(
       sid,
       FileSystemRights.Modify,
       InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
       PropagationFlags.None,
       AccessControlType.Allow));

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive