• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

General File Security question

How can I change the security settings of a file while preserving the
existing inherited access rules and also preventing the access rules from inheriting changes
in the future?
0
YZlat
Asked:
YZlat
  • 4
  • 2
1 Solution
 
Paul JacksonCommented:
Right-click the file and select properties.
Select the security tab and click the advanced button.
Uncheck 'Allow inheritable permissions from the parent to propagate to this object and all child objects. Include these entries explicitly defined here' checkbox
On the prompt click copy.
Now add any other permissions you want.
Click ok.
Click ok.
Job done
0
 
YZlatAuthor Commented:
LOL I mean programmatically, using C#. That's why i posted my question in programming zonefor C#
0
 
Paul JacksonCommented:
You can do this with the filesecurity class using the addaccessrule method.

http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesecurity.aspx
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
YZlatAuthor Commented:
jacko72, I know I can use this class, but how exactly can I accomplish changing the security settings of a file while preserving the existing inherited access rules and also preventing the access rules from inheriting changes
in the future?
0
 
YZlatAuthor Commented:
Figured out the answer: To set inheritance rules,  FileSecurity.SetAccessRuleProtection method should be used.

And to preservie existing inherited access rules and also prevent the access rules from inheriting changes in the future it should be called with two boolean parameters, true and true:
FileSecurity.SetAccessRuleProtection(true, true)
0
 
YZlatAuthor Commented:
Found the answer I was looking for on my own
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now