security - How can I get a list of Groups and User names for a given folder in C# -


i found code shows how list of users in given domain. i'm looking names single folder. searches aren't getting me far. below example of list i'm looking for.

enter image description here

thanks

i'm not entirely sure intend above list, obtain permission attributes intended directory. query this:

// variables: string folderpath = ""; directoryinfo dirinfo = null; directorysecurity dirsec = null; int = 0;  try {      // read our directory path.           {           console.write("enter directory... ");           folderpath = console.readline();      }      while (!directory.exists(folderpath));       // obtain our access control list (acl)      dirinfo = new directoryinfo(folderpath);      dirsec = dirinfo.getaccesscontrol();       // show results.      foreach (filesystemaccessrule rule in dirsec.getaccessrules(true, true, typeof(ntaccount)))      {           console.writeline("[{0}] - rule {1} {2} access {3}",           i++,           rule.accesscontroltype == accesscontroltype.allow ? "grants" : "denies",           rule.filesystemrights,           rule.identityreference.tostring());       } } catch (exception ex) {      console.write("exception: ");      console.writeline(ex.message); }  console.writeline(environment.newline + "..."); console.readkey(true); 

this basic example of querying directory obtain permission levels on it. you'll note show physical accounts associated well. should compile , show accounts associated directory.

i'm not sure if asking about- hope helps.


Comments