acl.GetOwner(typeof(NTAccount))

Discussion in 'ASP .Net Security' started by sirpooky@gmail.com, Jul 26, 2006.

  1. Guest

    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
    , Jul 26, 2006
    #1
    1. Advertising

  2. 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


    > 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
    >
    Dominick Baier, Jul 26, 2006
    #2
    1. Advertising

  3. 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:...
    > 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
    >
    >
    >> 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
    >>

    >
    >
    Joe Kaplan \(MVP - ADSI\), Jul 26, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PM
    Replies:
    1
    Views:
    358
    Natty Gur
    Nov 12, 2003
  2. mpes
    Replies:
    2
    Views:
    542
    Steven Cheng[MSFT]
    Jan 27, 2005
  3. djoledjole
    Replies:
    2
    Views:
    546
    djoledjole
    Apr 8, 2005
  4. Sosh123
    Replies:
    0
    Views:
    2,925
    Sosh123
    Jun 2, 2005
  5. Replies:
    1
    Views:
    408
    Joe Kaplan \(MVP - ADSI\)
    Aug 9, 2006
Loading...

Share This Page