I have a pdf file on a windows server running IIS7 that I use as a template to create a printable/offline version of my web form. I access it in an APS.NET application using an .ashx handler. Initially it worked fine, until I moved to Production, then it gave me Access to the path 'D:\inetpub\site\My PDF.pdf' is denied.
First I tried changing the App Pool identity, in case it was a permissions issue. I also added full control permissions for that identity. Doing this broke it in the lower environment as well. When the app pool was switched back to the original(ApplicationPoolIdentity), it still didn't work.
I'm finding the file via HttpContext.Current.Server.MapPath
, which works as expected. Then I'm using FileStream existingFileStream = new FileStream(fileNameExisting, FileMode.Open)
to open the file for editing via iTextSharp. The file has permissions for 'Network Service'.
Any help would be appreciated. Let me know if you need more information.
I apologize if this is the wrong site for this question. If it is, please let me know and I will move it to the proper one.
EDIT:
Below is the the permissions via icacls of the file in the production environment. MYDOMAIN, CustomAppIdentity, WEBSERVER, and LabManagers have names changed for security.
MYDOMAIN\CustomAppIdentity:(F)
NT AUTHORITY\NETWORK SERVICE:(F)
NT AUTHORITY\Authenticated Users:(I)(RX)
NT AUTHORITY\SYSTEM:(I)(F)
WEBSERVER\LabManagers:(I)(M)
BUILTIN\Administrators:(I)(F)
BUILTIN\Users:(I)(RX)
NT SERVICE\TrustedInstaller:(I)(F)
EDIT: Event Information
Event code: 4011
Event message: An unhandled access exception has occurred.
Event time: 7/1/2015 11:07:56 AM
Event time (UTC): 7/1/2015 6:07:56 PM
Event ID: 9c4a06e4465744da8d76e27f3d954c30
Event sequence: 48
Event occurrence: 3
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/8/ROOT/MyProject-1-130802388056279071
Trust level: Full
Application Virtual Path: /MyProject
Application Path: D:\inetpub\parent-site\MyProject\
Machine name: MYSERVER
Process information:
Process ID: 4236
Process name: w3wp.exe
Account name: IIS APPPOOL\MyProject
Request information:
Request URL: http://parentsite.url/MyProject/PdfHandler.ashx
Request path: /MyProject/PdfHandler.ashx
User host address: 159.1.15.73
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\MyProject
Custom event details:
icacls.exe "D:\inetpub\site\My PDF.pdf"
Access Denied
.Everyone
group access to the file.Everyone
full control. It still saysSystem.UnauthorizedAccessException: Access to the path 'E:\inetpub... etc...' is denied.
.