article

ASP.NET does NOT honor IIS security accounts by default!

Email
Submitted on: 1/1/2015 3:13:00 AM
By: Ian Ippolito (PSC)  
Level: Beginner
User Rating: By 10 Users
Compatibility: VB.NET, ASP.NET
Views: 972
author picture
 
     When working on a website that was supposed to use the new ASP.NET file upload object (great feature by the way) to upload files and then copy them to a network file server, I discovered that ASP.NET does not honor the security account that you setup in IIS by default! You have to override it to get it to do so. This article explains how and will hopefully save you some time and aggravation of your own.

 
				I was using the following simple code to copy a file.  It would work 
when copied to a local drive:

Dim strSourceFile, strDestFile As String
strSourceFile = "c:\temp\temp.txt"
Dim fileinfo2 As New FileInfo(strSourceFile)

strDestFile = "c:\temp2.txt"
fileinfo2.CopyTo(strDestFile, True)

But when I changed the file path to a UNC file path, it bombed with a permissions error.

strDestFile = "\\atcsrflfnp01\software\temp\temp.txt"
 

Setting IIS using the anonomous login account, like in ASP classic did not improve the situation at all...I still got the same error.

After doing quite a bit of reading and digging through the 'help' files, I found out that ASP.NET by default runs under its own system account, and doesn't honor IIS's settings!

Fortunately there is a simple way to fix this, once you realize the problem.  If you add the following to the <system> section of your web.config file, it will allow you to use the IIS account.

<identity impersonate="true"/>

You can also use this method to override IIS, if you specify a name and password paramater.


Other 5 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.