Link to home
Start Free TrialLog in
Avatar of kdirk
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-00600802DB86}
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.UnauthorizedAccessException: 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:


[UnauthorizedAccessException: 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(HtmlTextWriter __output, Control parameterContainer) in c:\inetpub\wwwroot\PM2\PM2_pdf.aspx:20
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   System.Web.UI.Control.Render(HtmlTextWriter writer)
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   System.Web.UI.Page.ProcessRequestMain()
=============================
 
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Enable impersonation for this page and see if it solves the problem:

<identity impersonate="true" userName=""  password=""/>            
-or-
<identity impersonate="true" />
Avatar of kdirk
kdirk

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.
Avatar of kdirk

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\wwwroot\au\docs\fa\pm2\ps\PM2Destination.ps"

SET GSDESTINATION="C:inetpub\wwwroot\au\docs\fa\pm2\pdf\PM2Form.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
Avatar of kdirk

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.Shell")
            WshExe.Run("C:\inetpub\wwwroot\au\docs\fa\pm2\bat\createpm2pdf.bat", 3, 1)
        Catch ex As Exception
            console.writeln(ex.ToString)
        Finally
        End Try




    End Sub
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial