How can I check Accessibility permissions on a folder using C #?

Hi I want to check if a specific folder is user accessible. for normal rights to shares, I can obtain information on

DirectoryInfo di = new DirectoryInfo(path);
    DirectorySecurity acl = di.GetAccessControl(AccessControlSections.All);
    AuthorizationRuleCollection rules = acl.GetAccessRules(true, true, typeof(NTAccount));

    //Go through the rules returned from the DirectorySecurity
    foreach (AuthorizationRule rule in rules)
    {
        //If we find one that matches the identity we are looking for
        if (rule.IdentityReference.Value.Equals(NtAccountName, StringComparison.CurrentCultureIgnoreCase))
        {
            //Cast to a FileSystemAccessRule to check for access rights
            if ((((FileSystemAccessRule)rule).FileSystemRights & FileSystemRights.WriteData) > 0)
            {
                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));
            }
        }
    }

      

But the problem with this approach is that if you share a folder with the Accessibility option as shown in the figure, it does not display the log entry.

How to calculate it?

advanced Share with a user

+3
c # directory .net access-control


source to share


No one has answered this question yet

Check out similar questions:

3575
How to list a transfer?
2058
How do I get a consistent byte representation of strings in C # without manually specifying the encoding?
1758
How do I generate a random int?
1743
What's the best way to give a C # auto property an initial value?
1742
How to calculate a person's age in C #?
1012
Can you view all the enumeration values?
867
How can I generate random alphanumeric strings?
615
How can I save a stream to a file in C #?
591
How do I delete all files and folders in a directory?
364
Virtualbox shared folder permissions



All Articles
Loading...
X
Show
Funny
Dev
Pics