Created
July 7, 2010 21:09
-
-
Save kradcliffe/467279 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As discussed on the mailing list: http://www.ruby-forum.com/topic/212515