We have a .net web application. The web application is setup in IIS and runs under an AppPool which runs under Domain\User1
This web application has C#.NET code that makes access to a file on server. Problem is that only Domain\User2 has rights to this file for read/edit.
We know that the .NET code will run under the credentials of the AppPool account (that is: Domain\User1). Hence if we try to read/write file in .NET code of the web application, then it will throw error.
What is the possible approaches I can use so that I can access this file? I am not allowed to change the AppPool user as per our company policy. If this was possible then the code could access/write to the file. Also, I cannot change the permission of the file and allow Domain\User2 access to it again because of company policy.
What other option do I have?
Can I run only the file read/write part of code as Domain\User2 via .NET code?