ASP.NET - reading and writing to the file system outside the application

Is there a way to access the file system outside of the current ASP.NET application without bypassing permissions IIS_IUSRS

? For example, if I wanted this line to work:

logStream = File.Open("C:\logs\app.log", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);

      

... I usually need to grant read and write permission to the C:\logs\app.log

group IIS_IUSRS

. This is annoying setting up an application on new systems where the directories to be accessed may be in different locations. Is there a way to tell ASP.NET which directories it should have access to?

+2


source to share


2 answers


You can do this using impersonation, but I strongly urge you not to. You are in very risky areas in terms of security. If you are not 100% sure about your ID access rights, you are impersonating yourself, then you risk allowing hackers to get into areas of your server that you did not intend. Setting up the ACL correctly takes a long time, and you do NOT want to just use the administrative or superuser. You want to customize the user specifically for this purpose, and if you do, you just add a step to what you are already doing.

The best solution would be to create an application to write to a folder managed by your application. Your installation can create a folder on your computer and grant permissions automatically, rather than relying on an existing system folder.



http://msdn.microsoft.com/en-us/library/ms998258.aspx#pagguidelines0001_impersonationdelegation

+6


source


You can also configure AppPool to run under an account with the appropriate credentials.



+2


source







All Articles