2

I have a folder on a shared server that folder has many files. I need to retrieve information about the Files Author Name (The name of the user who created or last updated he file in the folder).

I tried some code samples available on web but it gives the domain and the computer name but not the actual user/author name.

I tried below:

const string FILE = @"C:\temp\temp.txt";
var fs = File.GetAccessControl(FILE);
var sid = fs.GetOwner(typeof(SecurityIdentifier));
Console.WriteLine(sid); // SID
var ntAccount = sid.Translate(typeof(NTAccount));
var STRING = ntAccount.Value;
Console.Write(ntAccount); // DOMAIN\username

but it only gives DOMAIN\computer name.

Mustafa Özçetin
  • 1,893
  • 1
  • 14
  • 16
iftekharus
  • 21
  • 2
  • 1
    In order to track writes to files on a share, you'll need to enable [Detailed File Share auditing](https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/audit-detailed-file-share) on the machine hosting the share and then consume the resulting event log entries. – Mathias R. Jessen Jun 25 '23 at 18:23
  • 1
    Does this link help? https://stackoverflow.com/a/7445261/880990 – Olivier Jacot-Descombes Jun 25 '23 at 18:24

0 Answers0