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

Advertisements

One thought on “Deploy ClientUI Report Application Separately from Report Server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s