kdirk
asked on
PdfDistiller COM object says "Access denied"
Have Acrobat installed. Am trying to write an .eps file to a pdf file using the distiller com object. The code is in a .net aspx page and fails on this dim statement:
Dim AcroDist As New ACRODISTXLib.PdfDistiller
The error message is an access denied error. See "=====" below for the aspx auto generated error.
Am not impersonating. I've tried giving the asp_net, iis_usr, network services accounts read, write and execute privileges on the c:\program files\adobe, c:\inetpub\wwwroot\pm2 (the application directory), and C:\temp directories but with no success. I've also checked to make sure that the com object is referenced in my project.
When I check my event log it says,
Access denied attempting to launch a DCOM Server. The server is:
{1CD675B2-ECD1-11D1-B976-0 0600802DB8 6}
The user is NETWORK SERVICE/NT AUTHORITY, SID=S-1-5-20.
I checked the registry and sure enough this is the pdfdistiller com object. It was after looking at the event log that I added the NETWORK SERVICE acount's read, write and execute permissions to the c:\program files\adobe directory. As mentioned previously, this had no effect.
What do I need to do to get the com object to run?
VISUAL STUDIO GENERATED ERROR MESSAGE
========================== ====
Access is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessE xception: Access is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 98:
Line 99: 'create the distiller object
Line 100: Dim AcroDist As New ACRODISTXLib.PdfDistiller
Line 101: AcroDist.bShowWindow = False
Line 102:
Source File: c:\inetpub\wwwroot\PM2\PM2 _pdf.aspx. vb Line: 100
Stack Trace:
[UnauthorizedAccessExcepti on: Access is denied.]
PM2.PM2_pdf.MakePdf(Object PMFormNo) in c:\inetpub\wwwroot\PM2\PM2 _pdf.aspx. vb:100
ASP.PM2_pdf_aspx.__Render_ _control1( HtmlTextWr iter __output, Control parameterContainer) in c:\inetpub\wwwroot\PM2\PM2 _pdf.aspx: 20
System.Web.UI.Control.Rend erChildren (HtmlTextW riter writer)
System.Web.UI.Control.Rend er(HtmlTex tWriter writer)
System.Web.UI.Control.Rend erControl( HtmlTextWr iter writer)
System.Web.UI.Page.Process RequestMai n()
========================== ===
Dim AcroDist As New ACRODISTXLib.PdfDistiller
The error message is an access denied error. See "=====" below for the aspx auto generated error.
Am not impersonating. I've tried giving the asp_net, iis_usr, network services accounts read, write and execute privileges on the c:\program files\adobe, c:\inetpub\wwwroot\pm2 (the application directory), and C:\temp directories but with no success. I've also checked to make sure that the com object is referenced in my project.
When I check my event log it says,
Access denied attempting to launch a DCOM Server. The server is:
{1CD675B2-ECD1-11D1-B976-0
The user is NETWORK SERVICE/NT AUTHORITY, SID=S-1-5-20.
I checked the registry and sure enough this is the pdfdistiller com object. It was after looking at the event log that I added the NETWORK SERVICE acount's read, write and execute permissions to the c:\program files\adobe directory. As mentioned previously, this had no effect.
What do I need to do to get the com object to run?
VISUAL STUDIO GENERATED ERROR MESSAGE
==========================
Access is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessE
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 98:
Line 99: 'create the distiller object
Line 100: Dim AcroDist As New ACRODISTXLib.PdfDistiller
Line 101: AcroDist.bShowWindow = False
Line 102:
Source File: c:\inetpub\wwwroot\PM2\PM2
Stack Trace:
[UnauthorizedAccessExcepti
PM2.PM2_pdf.MakePdf(Object
ASP.PM2_pdf_aspx.__Render_
System.Web.UI.Control.Rend
System.Web.UI.Control.Rend
System.Web.UI.Control.Rend
System.Web.UI.Page.Process
==========================
ASKER
Don't need to impersonate.
In IIS 6, the default account for the default application pool (of which this app is a member) is NETWORK SERVICES. If I change the this default user to SYSTEM, the pdfdistiller COM object will run without error. A filemon session indicated that vbc.exe was unable to create a directory in c:\winodws due to an access denied error. In short SYSTEM has some privilege that I need to give to NETWORK SERVICES in either C:\WINDOWS or another directory that will allow the pdfdistiller com object to be instantiated. I suppose it is possible that the COM object itself may require SYSTEM privileges.
In IIS 6, the default account for the default application pool (of which this app is a member) is NETWORK SERVICES. If I change the this default user to SYSTEM, the pdfdistiller COM object will run without error. A filemon session indicated that vbc.exe was unable to create a directory in c:\winodws due to an access denied error. In short SYSTEM has some privilege that I need to give to NETWORK SERVICES in either C:\WINDOWS or another directory that will allow the pdfdistiller com object to be instantiated. I suppose it is possible that the COM object itself may require SYSTEM privileges.
ASKER
Worked on the problem by setting permissions on the dll directories, registry keys and more. Spent hours with a MS tech. No matter what we tried, couldn't get the com object to run on server 2003. Instead, decided to use ghostscript 8.14 to create my pdf from a ps file.
Plan to do this by calling a .bat file from my .net app.
Bat file
===========
@echo on
cd c:\
rem enter the location of the ghostscript bin directory
SET GSBINDIR=C:\gs\gs8.14\bin
rem enter the location of the ghostscript lib directory
SET GSLIBDIR=C:\gs\gs8.14\lib
SET GSSOURCE="C:\inetpub\wwwro ot\au\docs \fa\pm2\ps \PM2Destin ation.ps"
SET GSDESTINATION="C:inetpub\w wwroot\au\ docs\fa\pm 2\pdf\PM2F orm.pdf"
rem adjust the system path to include the ghostscript directories
SET PATH=%GSBINDIR%;%GSLIBDIR% ;%PATH%
rem and call PS2PDF to do the actual conversion
CALL PS2PDF.BAT %GSSOURCE% %GSDESTINATION%
:QUIT
Plan to do this by calling a .bat file from my .net app.
Bat file
===========
@echo on
cd c:\
rem enter the location of the ghostscript bin directory
SET GSBINDIR=C:\gs\gs8.14\bin
rem enter the location of the ghostscript lib directory
SET GSLIBDIR=C:\gs\gs8.14\lib
SET GSSOURCE="C:\inetpub\wwwro
SET GSDESTINATION="C:inetpub\w
rem adjust the system path to include the ghostscript directories
SET PATH=%GSBINDIR%;%GSLIBDIR%
rem and call PS2PDF to do the actual conversion
CALL PS2PDF.BAT %GSSOURCE% %GSDESTINATION%
:QUIT
ASKER
Am using a win2k3 machine. Tried several different approaches with system.diagnostics process, aspexec, stream reader. Ended up doing this:
Public Sub LaunchBat()
Dim WshExe
Try
WshExe = CreateObject("WScript.Shel l")
WshExe.Run("C:\inetpub\www root\au\do cs\fa\pm2\ bat\create pm2pdf.bat ", 3, 1)
Catch ex As Exception
console.writeln(ex.ToStrin g)
Finally
End Try
End Sub
Public Sub LaunchBat()
Dim WshExe
Try
WshExe = CreateObject("WScript.Shel
WshExe.Run("C:\inetpub\www
Catch ex As Exception
console.writeln(ex.ToStrin
Finally
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<identity impersonate="true" userName="" password=""/>
-or-
<identity impersonate="true" />