The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Proper Security for Crystal Reports Export

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Doug Thews

Posts: 866
Nickname: dougthews
Registered: Jul, 2003

Doug Thews is a software developer/manager for D&D Consulting Services with 18+ years of experience
Proper Security for Crystal Reports Export Posted: Sep 28, 2004 3:09 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Doug Thews.
Original Post: Proper Security for Crystal Reports Export
Feed Title: IlluminatiLand
Feed URL: http://apps5.oingo.com/apps/domainpark/domainpark.cgi?client=netw8744&s=JETBRAINS.COM
Feed Description: A technology blog for people enlightened enough to think for themselves
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Doug Thews
Latest Posts From IlluminatiLand

Advertisement
I uncovered something with the Crystal Reports Export() functionality that I thought
I'd pass along. As you may or may not know, Crystal Reports that comes with VS.NET provides
the capability to export reports to PDF, Word, Excel and many other formats via the method:
myReports.Export()


And, you set up all of the disk file export options like this:
// Get the data for the order and populate the dataset
sqlDataAdapter1.Fill(dsReportOrderDetails);

// Set up a new report based on the Crystal RPT class created
myReportDocument = new ReportOrders();
myReportDocument.SetDataSource(dsReportOrderDetails);

// Set a temporary location for the PDF export
strTempFileLocation = Session.SessionID.ToString() + ".pdf";

// Now set up the export options
myDiskFileOptions = new DiskFileDestinationOptions();
myDiskFileOptions.DiskFileName = Server.MapPath(strTempFileLocation);
myExportOptions = myReportDocument.ExportOptions;
myExportOptions.DestinationOptions = myDiskFileOptions;
myExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
myExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;


So, the result of this is that you get an export file called [sessionid].pdf placed in
your current ASP.NET application directory. Because we use Server.MapPath, we don't need
any other priviledges other than to be able to write to our own web app directory.

BUT, Crystal Reports has a little surprise for us. When creating the export, it creates its
own temporary file called TEMP_[originalfilename].pdf and places it in the directory pointed
to by %WINDIR%\Temp. And, since it's using local file access, you need to provide your app
with the ability to write to this directory by either changing the account that your ASP.NET app
impersonates, or by changing the account that the aspnet worker process uses as defined in
machine.config. If you fail to do this, you'll get an annoying exception about not being able

If you're interested in reading more about how Crystal Reports can be used to generate reports
inside ASP.NET apps, please refer to my October Getting Started Column in Visual Studio Magazine
titled Build Printable ASP.NET Pages.

Read: Proper Security for Crystal Reports Export

Topic: SharePoint Scaling Limits Previous Topic   Next Topic Topic: Thanks to PCPro UK.... and Microsoft !

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use