acl.GetOwner(typeof(NTAccount))

S

sirpooky

Hi All,

I have a file system watcher on a remote machine. When people create files/folders on the remote machine I need to see which user was responsible. As there are a number of users who are admins often when a file is created the following code shows BUILTIN\Administrators

FileSecurity acl = File.GetAccessControl(e.FullPath);
NTAccount user = (NTAccount)acl.GetOwner(typeof(NTAccount));
string UserName = user.Value;

I know there is a way to get the Domain\USerName of the user but I cant for the life of me remember. Anyone?
- Paul C
 
D

Dominick Baier

IIRC admins are treated differently when it comes to ownership

if bob (a normal user) is the owner of a file, you will also find bob in
the ownership info
if alice (an administrator) is the owner of a file, the admins groups shows
up in the ownership info.

I don't think you can get to the name of the owner if it is an administrator
(or was there a settings somewhere to control this?) - i am short of a test
environment at the moment - so i can't verify.

dominick
 
J

Joe Kaplan \(MVP - ADSI\)

This is correct. I think there is a policy that you can set on the machine
to change this so that the actual name of the administrator is set in the
owner field, but that isn't the default.

Joe K.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top