Crystal report access denied

ddl_ex5
ddl_ex5 used Ask the Experts™
on
Dear all,

I have created a crystal report in one of the sub folders on my web app.  I have created a web page with a button on it.  When the button is clicked the report should load up in a pdf format on the web browser.

The thing is I seem to be encountering a permissions issue but do not know how to reslove it.

When i click on the button i get the
System.Runtime.InteropServices.COMException: Access is denied.
error message.

I looked it up on google and tried an example which worked but is not what i need.

The article said to make sure in the web config file that impersonate was on and that the username and password were also stated
so i added

<identity impersonate="true" userName="Office\myusername" password="mypassword"/>

but tihs is not ideal if I am going to have multiple users logging onto the page to print view the report.

I then thought I would add the actual report into a sub folder and make that folder a virtual folder and on the folder permissions give Network Service complete access but this did not work either.

Many thanks in advance

Zal
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
What version of Crystal?

mlmcc

Author

Commented:
I'm using Visual studio 2008 running on .NET 2
the version of crystal is 10.5.3700.0
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
How are you calling the report?

I thought VS2008 required .Net 3.0.

mlmcc
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Author

Commented:
No in vs 2008 you can still run 2.0 apps.

I have created a crytal report in a folder directory under the web app i.e. localhost/apps/reporting/report/
This crytal report is not connected to any data sources as I do this at run time passing in the parameter values from my aspx page.

So the aspx page which sits under  localhost/apps/reporting/ contains a button which performs the following code
 Dim rptDocument As ReportDocument = New ReportDocument
        Dim strFileName As String = "DC_QCReport"
        Dim strFilePath As String = "~/apps/reporting/report/"
        Dim strFileLocation As String = Server.MapPath(strFilePath & strFileName & ".rpt")

        If Not (File.Exists(strFileLocation)) Then
            _warn("The crystal report does not exist.")
        Else
            rptDocument.Load(strFileLocation)
        End If
     
        rptDocument.SetParameterValue("dubbing", dropDubbing.SelectedItem.Text)
        rptDocument.SetParameterValue("visa", dropVisa.SelectedItem.Text)
        rptDocument.SetParameterValue("pdf", dropPDF.SelectedItem.Text)
        rptDocument.SetParameterValue("subtitle", dropSubtitle.SelectedItem.Text)
        rptDocument.SetParameterValue("logo", sbLogos.ToString())


        rptDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, strFileName & ".pdf")
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:

Author

Commented:
The article does not help me as I am developing a web app rather than a windows form.

Also my issue is with the Access to the file.  I'm 100% certain it has soemthing ot do with permissions, because When i have the username and password in the webconfig file
<identity impersonate="true" userName="Office\myusername" password="mypassword"/>

i can view the document on the web browser.

BUT i do not want the username and the password in the web config file as the report will be obtained by many people accessing the intranet.

Commented:
ddl_ex5

there is something we call report mapping

for vs2008 .net 3.5 refer below example
http://msdn.microsoft.com/en-us/library/ms227452.aspx

and for .net 2.0 refer
http://msdn.microsoft.com/en-us/library/ms227452(VS.80).aspx

One more thing

-> i will suggest to not to put the crystal report under localhost if you want to embed it seperately because you will have to give iis user permission to access the file.
for testing purpose put it in say C:\\reportname.rpt


AR


Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
Since Crystal doesn't store the username/password the only way is to
1.  Don't protect the data source
2.  Include the username/password as you have done
3.  Make the users log into the source
4.  Save the report with data and make it static for the users.

mlmcc

Author

Commented:
Not to worry,

I had moved the aspx page into its own folder, and creating a web config file where impersonate is set ot false as the root web cinfig file is set ot true.
I moved the rpt file into a folder called uploads where the permissions is set ot full for the asp.net accounts (iis_wpg and internet guest account)

This resolved the issue.  Its not perfect but it will have to do for now.

Commented:
>>I moved the rpt file into a folder called uploads where the permissions is set ot full for the asp.net accounts (iis_wpg and internet guest account)

didnt i suggest that

-> i will suggest to not to put the crystal report under localhost if you want to embed it seperately because you will have to give iis user permission to access the file.

Commented:
In order to solve the problem he gave iis user access to the folder which contained the report.

in my suggestion http:#24898892, i notified him to place the report somewhere else apart from the IIS folder so that he does not deal with permission issue for iis user but if he still intends to keep it there then he needs to give iis user access to that path which he did.
Commented:
I've deployed it ot the live server and it works the way that it worked on the localhost.

So I think I have managed to solve my own issue.

so can you please not object and allow me to close this question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial