D A

D A

  • NA
  • 1
  • 0

NTFS permissions set through System.Security.AccessControl don't take

Dec 11 2008 7:36 PM
I'm using System.Security.AccessControl library to add and delete NTFS permissions to files and folders (see code sample below).

    public static void addPermissions(String path, String user) {

            DirectoryInfo dInfo = new DirectoryInfo(path);
            DirectorySecurity dSecurity = dInfo.GetAccessControl();
            dSecurity.AddAccessRule(new FileSystemAccessRule(user,
                                                             FileSystemRights.FullControl,
                                                             InheritanceFlags.None,
                                                             PropagationFlags.None,
                                                             AccessControlType.Allow));
            dInfo.SetAccessControl(dSecurity);
    }


When checking properties' security tab of path in Windows Explorer, user is correctly added to the permissions list - but none of the individual permission boxes are checked - as if the FileSystemRights value was somehow "none" (which is not even a valid attribute).

Any thoughts on what I might be missing? Thank you.