ep File User Access Rights - Critical!

Hi All,

I want to get all the access rights on a file for a particular user. I was able to do so using the WindowsIdentity method, but this requires unsafe code, for the constructor WindowsIdentity(IntPtr userToken). We acquire the userToken using the Win 32 API LogonUser(userName,password,domainName).

I dont want to use the unsafe code method for this purpose due to some constraints. I wanted to know how can we get all the access rights on a file for a particular user.

Thanks in advance :)

-Sandeep



Answer this question

ep File User Access Rights - Critical!

  • Sean Connolly

    Hi Peter,

    Thanks for your help! Can we get the same functionality using the Cacls (command) utility I want to get complete access rights for a file for a particular user. This will include the owner of file, read access, write access, append acess, full access, execute access etc.

    Also, Is it possible to impersonate a user A and try to get the access rights for user B on a file, where user A is an administrator.

    Thanks in advance !

    -Sandeep

     


  • DeanoCalver

    There's nothing in the framework that will let you do what you want without unsafe code.

    I would suggest you write a separate assembly to do the unsafe work, then an admin can grant the appropriate permissions to that assembly or register it in the GAC.

  • vina

    Hi,

    One more sample I got on the internet is :

    http://www.gotdotnet.com/Community/UserSamples/Details.aspx SampleGuid=e6098575-dda0-48b8-9abf-e0705af065d9

    Thanks n Happy coding !

    -Sandeep


  • ep File User Access Rights - Critical!