Is it possible to get credentials of a user who copied a file to a network share?
-
29-04-2021 - |
質問
I have a network share watched by a FileSystemWatcher
object...
If multiple users on a windows domain have access to copy files to this share, is it possible, using the FileSystemWatcher
object, or otherwise, to get credentials of a person who copied the file to this network share and how?
解決
I used FileInfo.GetAccessControl
method to get FileSecurity
object. Using GetOwner
method of that FileSecurity
object you can get the Principal.NTAccount
object to get the NT user...
var fi = new FileInfo(filePath);
var ac = fi.GetAccessControl();
var owner = ac.GetOwner(typeof (System.Security.Principal.NTAccount)).Value;
所属していません StackOverflow