PdfDistiller COM object says "Access denied"

Posted on 2004-11-16
Last Modified: 2008-01-09
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:

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?

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)
Question by:kdirk
    LVL 19

    Expert Comment

    by:Daniel Van Der Werken
    Enable impersonation for this page and see if it solves the problem:

    <identity impersonate="true" userName=""  password=""/>            
    <identity impersonate="true" />

    Author Comment

    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.

    Author Comment

    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\"

    SET GSDESTINATION="C:inetpub\wwwroot\au\docs\fa\pm2\pdf\PM2Form.pdf"

    rem adjust the system path to include the ghostscript directories

    rem and call PS2PDF to do the actual conversion


    Author Comment

    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

                WshExe = CreateObject("WScript.Shell")
                WshExe.Run("C:\inetpub\wwwroot\au\docs\fa\pm2\bat\createpm2pdf.bat", 3, 1)
            Catch ex As Exception
            End Try

        End Sub

    Accepted Solution

    PAQed with points refunded (125)

    Community Support Moderator

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Phishing is at the top of most security top 10 efforts you should be pursuing in 2016 and beyond. If you don't have phishing incorporated into your Security Awareness Program yet, now is the time. Phishers, and the scams they use, are only going to …
    If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
    Notifications on Experts Exchange help you keep track of your activity and updates in one place. Watch this video to learn how to use them on the site to quickly access the content that matters to you.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now