Tag Archives: Deployment Scenarios

Deploy ClientUI Report Application Separately from Report Server

Today I start to create a simple Silverlight project that uses Intersoft SqlReportViewer. This project will be used to display Microsoft SQL Server 2008 Reporting Services (further abbreviated as SSRS) document. The objective is to create SqlReportViewer application where the SSRS is located in different server.

The first step begins with creating a new project using Intersoft ClientUI MVVM Application project template.

ProjectTemplate

After the project creation completed, you need to configure SqlReportViewer at first. Specifically, the following tasks are required in order to start using SqlReportViewer in your application:

  • Register the SqlReportViewer rendering engine in SQL Reporting Services.
  • Register the SqlReportViewer handler and SQL Reporting Services web service in the web project.
  • Set the SqlReportViewer proxy and web service property.

For more information on how to configure SqlReportViewer for first time use, it is suggested to check ClientUI documentation, Walkthrough: Configuring SqlReportViewer for First Time Use.

<Intersoft:SqlReportViewer x:Name="SqlReportViewer1"
                Intersoft:DockPanel.IsFillElement="True"
                ZoomMode="FitToWidth"
                ReportProxyHandler="http://Saturn-PC/MySqlReportViewer/ReportDocumentStreamer.ashx"
                ReportServer="http://Uranus-PC/ReportServer"
                ReportExecutionServicePage="ReportExecution2005.asmx"
                ReportServicePage="ReportService2010.asmx"
                RenderingExtensionName="Chart_Intersoft_XAML"
                ReportName="/Northwind Reports/ProductSalesReport"
                LoadingMode="OnDemand">
</Intersoft:SqlReportViewer>

As you may see on the XAML code, the ReportProxyHandler and the ReportServer properties are set to different location of server. The project will be deployed on the deployment server, Saturn-PC. There will be another server, Uranus-PC, which will act as the SSRS server.

For this kind of scenario, you need to create a custom SqlReportViewer handler. The reason is because by default, the Intersoft SqlReportViewer handler uses Impersonate as the TokenImpersonationLevel. This means that the server process can impersonate the client’s security context on its local system. The server cannot impersonate the client on remote server.

The screenshot below shows what will happen when we use the default SqlReportViewer handler.

Exception

The impersonation level and network credential are handled by the SqlReportViewer handler. We need to add a class which inherits SqlReportViewerHandler, then set the ImpersonationLevel and NetworkCredential to the proper value.

Open the project and add a class library project, named as ExtendedSqlReportServer.

AddExtendedClass

Add the following code into the Class1.cs file.

//NewClass1 inherits from Intersoft.SqlReportViewer.Server.SqlReportViewerHandler
class Class1:Intersoft.SqlReportViewer.Server.SqlReportViewerHandler
{
    private System.Security.Principal.TokenImpersonationLevel newImpersonationLevel;
    private System.Net.NetworkCredential newWindowsClientCredential;

    //Override the ImpersonationLevel property
    //modify the default Impersonation to None
    public override System.Security.Principal.TokenImpersonationLevel ImpersonationLevel
    {
        get
        {
            newImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.None;
            return newImpersonationLevel;
        }
        set
        {
            newImpersonationLevel = value;
        }
    }

    //Override the WindowsClientCredential property
    //set the NetworkCredential to the proper credential of SqlReport Report Server
    public override System.Net.NetworkCredential WindowsClientCredential
    {
        get
        {
            newWindowsClientCredential = new System.Net.NetworkCredential("username", "password", "Saturn-PC");
            return newWindowsClientCredential;
        }
        set
        {
            newWindowsClientCredential = value;
        }
    }
}

As seen in the code above, the ImpersonationLevel property is overridden to return TokenImpersonationLevel.None, while the WindowClientCredential property is overriden to return the NetworkCredential object with proper user credential who has sufficient security permission to access the SSRS server. Of course, you should encrypt or obfuscate your code for the best security, especially when it contains security sensitive information.

After building the ExtendedSqlReportServer project, add the ExtendedSqlReportServer assembly file as References into the Web project. Finally, you redefine the SqlReportViewer handler using the new handler assembly.

In this post, you have learnt how to configure SqlReportViewer where the SqlReport service is deployed on remote server.

Should you find this post useful, or have any questions or feedback, please feel free to drop me a line in the comment box.

Best Regards,
Yudi Ariawan

Introducing ImageAbsolutePath Feature in SqlReportViewer

The recently released service pack includes a number of enhancements to the SqlReportViewer control. One of the enhancements is the addition of ImageAbsolutePath property. This property is introduced for use in scenario involving multiple server environment.

In the initial release, ImageAbsolutePath is inferred from ImageVirtualPath. In this case, the control always assume that the SqlReportViewer and SQL Reporting Service is located on the same server. However, based on customer feedback, scenarios involving multiple server location is common in enterprise application deployment.

For example, the SqlReportViewer service is hosted on ssrs-1 server while the SqlReportingService is located on web-1. The scenario requires user to set both the ImageVirtualPath and ImageAbsolutePath properties, because the inferred absolute path from a remote location will not return a correct result. A code snippet to address such scenario would be:

<Intersoft:SqlReportViewer x:Name="ReportViewer1" 
	ReportProxyHandler="http://web-1/SqlReportViewerHandler.ashx" 
	ReportName="/Northwind Reports/SalesOrderInvoice"
	ReportServer="http://ssrs-1/ReportServer"
	ImageVirtualPath="http://ssrs-1/TempImages/"
	ImageAbsolutePath="C:\inetpub\wwwroot\TempImages" /> 

The above code snippet assumes that the report images will be stored to the C:\inetpub\wwwroot\TempImages folder on the ssrs-1 server and virtually hosted on http://ssrs-1/TempImages. In this case, you need to configure ssrs-1 as the image server by creating the TempImages virtual directory.

If opening up the SQL report server as public web server is not option, simply set the ImageVirtualPath property to the web-1 server. Everything else should remain the same. In this case, you need to configure the IIS in the web-1 server by creating a virtual directory and map it to the network path in the ssrs-1 server.

I hope this post gives you insights on the new ImageAbsolutePath feature and how it can be used along with other properties to achieve advanced deployment scenarios. Any questions or feedback are welcomed.

For the complete list of enhancements and fixes in the latest ClientUI release, please visit our support page.

Regards,
Glenn Layaar