Common Considerations for Custom Reporting Services Extensions: Implementation, Deployment, and Security


The reporting library provides three namespaces that supply interface definitions, classes, and value types that allow extensions to interact with SSRS:

  • Microsoft.ReportingServices.DataProcessing Used to extend the dataprocessing capability of SSRS.

  • Microsoft.ReportingServices.Interfaces Used to build delivery and security extensions.

    This namespace also allows you to maintain a cross-connection state. A class that implements the IExtension interface from this namespace is kept in memory for as long as SSRS is running.

  • Microsoft.ReportingServices.ReportRendering Used to extend the rendering capabilities of SSRS. This namespace is used in conjunction with the Microsoft.ReportingServices.Interfaces namespace.

Before you can successfully compile an extension, you must supply the reference to one or more Microsoft.ReportingServices namespaces as follows :

 using Microsoft.ReportingServices.Interfaces; 

A namespace can have optional interfaces, such as IDbConnectionExtension in Microsoft.ReportingServices.DataProcessing , and required interfaces, such as IDbConnection in the same extension's namespace. When an interface is required and a developer chooses not to implement a particular property or method of the interface, it is a best practice to throw a NotSupportedException . NotSupportedException is most appropriate for this purpose as it indicates methods (and properties) that did not provide implementation for methods described in the base classes (interfaces). The next best alternative is NotImplementedException . Note that optional interfaces do not require implementation at all.

Any Common Language Runtime (CLR) application interacts with the CLR security system. This book briefly covered the basics of .NET security in Chapter 23, "How to Create and Call a Custom Assembly from a Report," specifically in the section ".NET Security Primer for a SSRS Administrator." The same principles apply to extensions. Local security settings and SSRS configuration files define the code permissions that an extension's assembly receives. SSRS extensions must be a part of a code group that has the FullTrust permission set.

To deploy an assembly, a SSRS administrator must have appropriate permissions to write to the Report Server directory, Report Designer directory, and configuration files.

When a Report Server first loads an extension in memory, the Report Server accesses an assembly using service account credentials. Service account credentials are needed so an extension can read configuration files, access system resources, and load dependent assemblies (if needed). After an initial load, the Report Server runs an assembly using credentials of the user who is currently logged in.

An extension can be deployed for use by the Report Server, Report Manager, Report Designer, or all of the above. This is provided that the extension can be used by a tool. For example, Report Manager only uses delivery extensions.

The deployment procedure for an extension used by the Report Server, Report Manager, or Report Designer is basically the same, the only difference is the deployment directory and configuration files that need to be modified. To simplify further discussion, this book uses the following abbreviations:

  • {AssmDir} To abbreviate assembly deployment directories. The default Report Server binary directory is C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ ReportServer \bin . The default Report Designer binary directory is C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies . The default Report Manager binary directory is C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager\bin .

  • {ConfigFile} To abbreviate configuration files (note the default file path ). The default location for the Report Server configuration file is C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\ RSReportServer.config . The default location for the Report Designer configuration file is C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\ RSReportDesigner.config . The default location for the Report Manager configuration file is C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager\ RSWebApplication.config .

  • {SecConfig} To abbreviate security configuration files. The default location for the Report Server security configuration file is C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\ RsSrvPolicy.config . The default location for the Report Designer security configuration file is C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\ RSPreviewPolicy.config . The default location for the Report Manager security configuration is C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\ RsMgrPolicy.config.

To deploy an extension, a report administrator can use the following steps:

1.
Copy an extension assembly to the {AssmDir} directory. Remember to substitute {AssmDir} with any of the three directories this shortcut abbreviation. If an assembly with the same name exists in the {AssmDir} directory, stop the Report Server service, copy an assembly, and then restart the Report Server service.

2.
Locate an entry in the {ConfigFile} under the <Extensions> tag tag ({ConfigFile} directories)> tag> that corresponds to a category ( {ExtCategory} ) of an extension: <Delivery> , <Data> , <Render> , <Security> (Authorization), <Authentication> , or <DeliveryUI> .

3.
Add an entry for a newly created extension to a {ConfigFile} .

 <Extensions>      ...      <(ExtCategory}>         <Extension             Name="{Unique extension name up to 255 characters}"             Type="{Fully qualified name of the class implementing   IExtension},                   {AssemblyName without .dll}"             Visible="{falsetrue; false indicates that extension is not   visible in UI}"          >          {optional configuration data}          </Extension>       </(ExtCategory}>       ...    </Extensions> 

An example of CustomFileShareProvider for rsreportserver.config is as follows:

 <Extensions>    <Delivery>         <Extension           Name="Report Server Custom FileShare"          Type="MyCorp.FileShareDeliveryProvider.CustomFileShareProviderClass,          CustomFileShareProviderAssembly"        >        <MaxRetries>3</MaxRetries>        <SecondsBeforeRetry>900</SecondsBeforeRetry>        <Configuration>           <StoreResultsAt>             <FileShare>\myserver1\result</FileShare>             <FileShare>\myserver2\result</FileShare>           </StoreResultsAt>        </Configuration>      </Extension>      ... 

When an extension that implements the IExtension interface is invoked, SSRS calls two methods of the IExtension interface: SetConfiguration and LocalizedName . SSRS passes an XML fragment between <Configuration> and </Configuration> tags in the configuration file as a parameter to SetConfiguration , so the extension can take advantage of the flexibility that configuration offers. The LocalizedName property targets user interface implementations (such as Report Manager) and should return values for various languages. This way, an extension can be used around the world and does not have to be recompiled every time the extension is deployed in a new locale.

4.
Finally, an administrator can grant FullTrust permission for an assembly by modifying the {SecConfig} file:

 <CodeGroup class="UnionCodeGroup"    version="1"    PermissionSetName="  FullTrust  "    Name="MyExtensionCodeGroup"    >       <IMembershipCondition class="UrlMembershipCondition"         version="1"        Url="C:\Program Files\Microsoft SQL Server\MSSQL\Reporting  Services\ReportServer\bin\MyExtensionAssembly.dll"       /> </CodeGroup> 

5.
An administrator can verify deployment of an extension by using the ListExtensions method.

Note

Additional details about security are covered in Chapter 23, specifically in the section ".NET Security Primer for a SSRS Administrator."


To debug a deployed extension, complete the following steps:

1.
Determine the processes that access the extension. For example, for a delivery extension that is accessed by Report Manager (because Report Manager runs in the content of IIS), the process is aspnet_wp.exe or w3wp.exe . Similarly, the subscription notification event is handled by SSRS, and SSRS (the process is ReportingServicesService.exe ) invokes a delivery extension to execute a delivery. A data-processing extension can be accessed by Report Manager and from within an instance of Visual Studio (the process is devenv.exe ).

2.
Set breakpoints in the extension's code.

3.
Attach Visual Studio to the calling process using, for example, the Debug, Attach to Process menu. The Attach to Process dialog box opens. You need to make sure that Show Processes from All Users check box is selected, after which you can select a process to attach to, and click Attach.

4.
As the extension is invoked, Visual Studio breaks at set breakpoints, and you can step through the code.



Microsoft SQL Server 2005 Reporting Services
Microsoft SQL Server 2005 Reporting Services
ISBN: 0672327996
EAN: 2147483647
Year: 2004
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net