Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Undeleting post:</p> <p>I had written up this bit of code earlier, unfortunately it is CLR/.NET specific. However, since you professed that using 'the API' is hard (it is, I did it 10 years ago and NTFS ACLS are no picknick), you might be motivated by the below sample to integrate a bit of .NET code (C++/CLI or Interop based?)</p> <hr> <p>Any specific reason not to use C# code?</p> <pre><code>AddFileSecurity(fileName, @"DomainName\AccountName", FileSystemRights.ReadData, AccessControlType.Allow); RemoveFileSecurity(fileName, @"DomainName\AccountName", FileSystemRights.ReadData, AccessControlType.Allow); </code></pre> <p>With the following helpers from <a href="http://msdn.microsoft.com/en-us/library/ms229078.aspx" rel="nofollow">MSDN: How to: Add or Remove Access Control List Entries</a>:</p> <pre><code>public static void AddFileSecurity(string fileName, string account, FileSystemRights rights, AccessControlType controlType) { FileSecurity fSecurity = File.GetAccessControl(fileName); fSecurity.AddAccessRule(new FileSystemAccessRule(account, rights, controlType)); File.SetAccessControl(fileName, fSecurity); } public static void RemoveFileSecurity(string fileName, string account, FileSystemRights rights, AccessControlType controlType) { FileSecurity fSecurity = File.GetAccessControl(fileName); fSecurity.RemoveAccessRule(new FileSystemAccessRule(account, rights, controlType)); File.SetAccessControl(fileName, fSecurity); } </code></pre> <p>See the article for full details and comments</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload