I want to perform Sync operation with network folder or shared folder. Before performing the sync, I want to check all the permissions with that folder. Actually there are 13 permissions in windows NTFS folder.
First I need to perform below tasks one by one.
List out all the 13 permissions of the windows share folder and store it in List<T>.
The NTFS 13 permissions list:
• Traverse folder / execute file
• List folder / read data
• Read attributes
• Read extended attributes
• Create files / Write data
• Create folders / append data
• Write attributes
• write extended attributes
• Delete subfolders and files
• Delete
• Read permissions
• Change permissions
• Take ownership
After that based on the permissions only I need to start the Sync.
I tried with below code but I got only 5 permissions “Write, Read, Full control, Create, Delete”
Any one please tell me possible solution for doing this functionality.
What I have tried:
string path = @"C:\ExportFolder";
string NtAccountName = @"MyDomain\MyUserOrGroup";
DirectoryInfo di = new DirectoryInfo(path);
DirectorySecurity acl = di.GetAccessControl(AccessControlSections.All);
AuthorizationRuleCollection rules = acl.GetAccessRules(true, true, typeof(NTAccount));
foreach (AuthorizationRule rule in rules)
{
if (rule.IdentityReference.Value.Equals(NtAccountName, StringComparison.CurrentCultureIgnoreCase))
{
var filesystemAccessRule = (FileSystemAccessRule)rule;
if ((filesystemAccessRule.FileSystemRights & FileSystemRights.WriteData) > 0 && filesystemAccessRule.AccessControlType != AccessControlType.Deny)
{
Console.WriteLine(string.Format("{0} has write access to {1}", NtAccountName, path));
}
else
{
Console.WriteLine(string.Format("{0} does not have write access to {1}", NtAccountName, path));
}
}
}