Skip to content

Instantly share code, notes, and snippets.

@kradcliffe
Created July 7, 2010 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kradcliffe/467279 to your computer and use it in GitHub Desktop.
Save kradcliffe/467279 to your computer and use it in GitHub Desktop.
def add_acl app_path, desiredFilesystemRights, groupOrAccountName
di = DirectoryInfo.new app_path
ds = di.GetAccessControl
simple_rule = FileSystemAccessRule.new(
groupOrAccountName,
desiredFilesystemRights,
AccessControlType.Allow
)
full_rule = FileSystemAccessRule.new(
groupOrAccountName,
desiredFilesystemRights,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.InheritOnly,
AccessControlType.Allow
)
#Both rules need to run to give rights
ds.AddAccessRule(simple_rule)
ds.AddAccessRule(full_rule)
Directory.SetAccessControl app_path, ds
puts "Gives #{groupOrAccountName} #{desiredFilesystemRights} to #{app_path}"
end
@kradcliffe
Copy link
Author

As discussed on the mailing list: http://www.ruby-forum.com/topic/212515

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment