I have an ASP.NET web application using Windows authentication and impersonation. Here's the relevant part of web.config:
<authentication mode="Windows"/>
<identity impersonate="true"/>
The application code now tries to access a file (XDocument.Load
) that the authenticated user has access to. This worked perfectly fine until today we started getting the following exception instead:
System.UnauthorizedAccessException: Access to the path '...' is denied.
(Obviously, the admin tells me that "nothing has changed on the server".)
I was able to "fix" the issue by granting the application pool identity permission to the file. However, I don't understand why this fixed the problem.
My question: If impersonation is used, why is it still necessary for the application pool identity to have access to the files used? Do both the impersonated user and the application pool identity need access? Or only the application pool identity? If the latter, what's the point of impersonation?