0

On a local network I'm using this code :

string user = System.IO.File.GetAccessControl(path).GetOwner(typeof(System.Security.Principal.NTAccount)).ToString();

This returns : "BUILTIN\Administrators" Not The Session UserName which created the file.
As I understand the UserName is part of the group "BUILTIN\Administrators".
So is there anyway to retrieve the session UserName ?

Note : I can use ActiveDirectory if this can help me out.

DeanOC
  • 7,142
  • 6
  • 42
  • 56
  • What is a "session username"? If the user creating a file is in the local administrators group, the latter becomes the owner. http://stackoverflow.com/questions/3370146/how-can-i-find-out-who-created-a-file-in-windows-using-net – CodeCaster Jul 26 '15 at 23:03
  • Session username means here the name that appears on the logon screen. –  Jul 27 '15 at 01:47
  • _What_ logon screen? Is this a desktop or web application? Again, if the currently logged on user (desktop) or the user running the application pool (IIS) is a member of the local administrators group, you'll get the behavior you're seeing. You can't change this, other than writing the file as a different user. – CodeCaster Jul 27 '15 at 09:33

0 Answers0