Welcome to DevAuthority.Com Sign in | Join | Help

SetAccessRuleProtection and Inherited NTFS Permissions

Continuing from my last post, the same can be achieved using SetAccessRuleProtection as shown below:


using System;
using System.Collections.Generic;
using System.Text;
using System.Security.AccessControl;
using System.IO;
using System.Security.Principal;


namespace AceInheritRemove
{
class Program
{
static void Main(string[] args)
{
// Get the object and its SecDescp
DirectoryInfo dir = new DirectoryInfo("e:\\kgk\\test");
DirectorySecurity sec = dir.GetAccessControl(AccessControlSections.All);


sec.SetAccessRuleProtection(true, false);


// Create a child folder with the explicit permissions only...
DirectoryInfo info2 = new DirectoryInfo("e:\\kgk\\Test\\Child");
info2.Create(sec);


dir.SetAccessControl(sec);
}
}
}


Published Tuesday, July 12, 2005 12:06 PM by gkhanna
Filed Under: ,

Comments

No Comments
New Comments to this post are disabled