Groups | Blog | Home
all groups > asp.net security > july 2006 >

asp.net security : acl.GetOwner(typeof(NTAccount))


sirpooky NO[at]SPAM gmail.com
7/26/2006 3:00:38 AM
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?
Joe Kaplan (MVP - ADSI)
7/26/2006 9:17:34 AM
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.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"Dominick Baier" <dbaier@pleasepleasenospam_leastprivilege.com> wrote in
message news:4580be6389798c87ec588da64f0@news.microsoft.com...
[quoted text, click to view]

Dominick Baier
7/26/2006 10:24:11 AM
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


[quoted text, click to view]

AddThis Social Bookmark Button