none
setting file permission on remote server in c#

    Question

  • Hi,

    Can any help me out, how to set file permission on remote server in asp.net application?. I need to change the file permission from my .net web application. is it possible? if it is, can any share the solution.

     

    Thanks,

    Kesav

    Friday, August 12, 2011 1:07 PM

Answers

  • No it is not possible.  ASP.NET applications almost always run under a local account without sufficient privileges to change file system locally not to mention remotely.  Even if an ASP.NET app runs under the context of a domain user it still only sees a file share which has only RW access (not the real NTFS permissions).  In theory you could use File.GetAccessControl with a full UNC path and then try to make the changes but your web app would need to have way more permissions than is appropriate for a web app or you'd need to use impersonation.

    There are tools available that you can run to change the permissions on a remote file system.  Google for them.  You could have your web app run the command in isolation (Process class) with impersonation.  This seems a better approach. 

    Michael Taylor - 8/12/2011
    http://msmvps.com/blogs/p3net

    Friday, August 12, 2011 1:15 PM
    Moderator

All replies

  • No it is not possible.  ASP.NET applications almost always run under a local account without sufficient privileges to change file system locally not to mention remotely.  Even if an ASP.NET app runs under the context of a domain user it still only sees a file share which has only RW access (not the real NTFS permissions).  In theory you could use File.GetAccessControl with a full UNC path and then try to make the changes but your web app would need to have way more permissions than is appropriate for a web app or you'd need to use impersonation.

    There are tools available that you can run to change the permissions on a remote file system.  Google for them.  You could have your web app run the command in isolation (Process class) with impersonation.  This seems a better approach. 

    Michael Taylor - 8/12/2011
    http://msmvps.com/blogs/p3net

    Friday, August 12, 2011 1:15 PM
    Moderator
  • Thanks CoolDadTx for your great help.

    By the way, it's more likely to get more efficient responses to ASP.NET questions at http://forums.asp.net where you can contact ASP.NET experts.


    Martin Xie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, August 17, 2011 11:56 AM
    Moderator