0

How to get the names and location of the folders which are created with "Everyone" privilage in a current system

  • Take a look at the answers to [this question](http://stackoverflow.com/questions/1410127/c-sharp-test-if-user-has-write-access-to-a-folder). You should be able to implement that for your own needs. – John Willemse Apr 12 '13 at 12:37
  • `icacls c:\ /findsid everyone /T` and then capture the output – Steve Apr 12 '13 at 12:45

1 Answers1

0

You can use DirectoryInfo.GetAccessControl to get

Gets a DirectorySecurity object that encapsulates the access control list (ACL) entries for the directory described by the current DirectoryInfo object.

for a single directory in system. The rest is a matter of implementation of iteratiing over all dircetories in the system and calling this.

Example:

    string[] drives = System.Environment.GetLogicalDrives();
    foreach (string dr in drives)
    {
        System.IO.DriveInfo di = new System.IO.DriveInfo(dr);


        if (!di.IsReady)
        {               
            continue;
        }
        System.IO.DirectoryInfo root = di.RootDirectory;
        var directories = root.GetDirectories("*.*", System.IO.SearchOption.AllDirectories);
        foreach(var dirInfo in directories ) {
            var diAccess = dirInfo.GetAccessControl(..) ;
        }

    }

Complete example and explanation can find: How to: Iterate Through a Directory Tree

This is just a sketch, change it to fit your needs.

Tigran
  • 61,654
  • 8
  • 86
  • 123