Sai Avinash
Sai Avinash

Reputation: 4753

Displaying permissions of a folder for all users and groups using C# Programatically

I am working on a requirement where i need to display the permissisons of a folder for all Users and Groups programatically using C#.

Here, is the code, i am using to do it:

 DirectorySecurity filesecure = Directory.GetAccessControl(txtPath.Text);

 StringBuilder strbldACLlist = new StringBuilder();

 filesecure.GetSecurityDescriptorSddlForm(AccessControlSections.All);

 foreach (FileSystemAccessRule ace in filesecure.GetAccessRules(true, true, typeof(NTAccount)))
                {
                    strbldACLlist.Append(ace.FileSystemRights + ":" + ' ' + ace.IdentityReference.Value + "\n");
                }

I am getting the output like this:

"ReadAndExecute, Synchronize: dm1\\55555\nFullControl: dm1\\343556\n268435456: dm1\\343556\nFullControl: NT AUTHORITY\\SYSTEM\n268435456: NT AUTHORITY\\SYSTEM\nFullControl: BUILTIN\\Administrators\n268435456: BUILTIN\\Administrators\n"

Here, for the first user i am getting properly the file permissions. But, if you see the second userid i.e 343556 , i am getting result two times as you can see Full Control for first time nad some number n268435456 which i do not under stand.

Can any one please analyze the output and explain what's happening actually..

Upvotes: 0

Views: 160

Answers (1)

simon at rcl
simon at rcl

Reputation: 7344

Have a look here. It's saying that FileSystemAccessRights is a Flags enum (i.e. its values can be or-ed). The actual number you've got 268435456 - is a combination for which a name hasn't been supplied.

Cheers -

Upvotes: 1

Related Questions