2

I am developing an application in C#. The goal is to get the permissions on a given file in the file system.

This would include inherited permissions and permissions directly assigned to the file.

I want to get AD groups, local groups and domain users and local users who have been assigned Read, Write, Read & Execute, List Folder Contents, Modify and Full Control on a given file.

I am not sure how to get the above for a given file. Any ideas ?

Vinay Joseph
  • 5,515
  • 10
  • 54
  • 94

1 Answers1

1

You want to create a FileIOPermission object for each file and pick out the AllFiles member. It can be any combination of AllAccess, Append, NoAccess, PathDiscovery, Read, and Write, though obviously only a few of those make logical sense.

You might also be interested in the GetPathList() method, obviously.

For the rest, there's also the System.DirectoryServices.AccountManagement namespace. That'd be too big for me to dig into, here, but...ah, this answer is a really good start.

Community
  • 1
  • 1
John C
  • 1,931
  • 1
  • 22
  • 34