Solved

General File Security question

Posted on 2011-03-11
6
271 Views
Last Modified: 2012-06-21
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
Comment
Question by:YZlat
  • 4
  • 2
6 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35109312
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
 
LVL 35

Author Comment

by:YZlat
ID: 35111127
LOL I mean programmatically, using C#. That's why i posted my question in programming zonefor C#
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 35134277
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 35

Author Comment

by:YZlat
ID: 35158642
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
 
LVL 35

Accepted Solution

by:
YZlat earned 0 total points
ID: 35164924
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
 
LVL 35

Author Closing Comment

by:YZlat
ID: 35196567
Found the answer I was looking for on my own
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reading the Web.Config using IIS 7.5? 4 49
Problem!!! 8 37
Dynamics CRM Plugin Query TotalRecordCount returning -1 13 43
Adding items to a C# list incrementally 5 30
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question