匿名访问ReportService报表服务器(一)

2023-05-25,,

  我的数据库版本是sql server 2008 r2,系统环境是windows server2008.

  对于sql server 2008 r2上报rs报表匿名访问问题,我这边尝试过两个可行方案:

  (1)使用ReportViewer展现报表,实现ReportViewer.ReportServerCredentials 对应的接口IReportServerCredentials,在接口中指定特定的用户名和密码。

  (2)直接访问RS报表页面,通过修改RS配置文件和SQL团队技术博客所提供的认证和安全节点下扩展类。

  (3)直接访问RS报表页面,指定用户名和密码来认证(我想这个可能性也是有的,只是没有做实验)

  两种方案比较:

  方案(1)实现起来简单,但ReportViewer本身内存泄漏的问题,建议不要轻易尝试,另外它不是根本上的匿名访问,实际使用的时候需要配置用户名和密码。

  方案(2)配置起来比较繁琐,但却是真正意义上的匿名访问。

  由于第二种方案能解决我现有项目的问题,所以本篇博客专注写第二种方案的实现方式。

  需要修改的配置和使用的资源:

  (1)*:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer 文件夹下的web.config、rssrvpolicy.config和rsreportserver.config

  (2)*:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportManager文件夹下的web.config

  (3)Microsoft.Samples.ReportingServices.AnonymousSecurity.dll(微软SQL技术博客提供的扩展类)

  配置Steps:

  (1)将文件Microsoft.Samples.ReportingServices.AnonymousSecurity.dll拷贝到*:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin目录下的。

  (2)对于上面提到的两个web.config文件,将下面代码

<authentication mode="Windows" />
<identity impersonate="true" />

替换成

<!--<authentication mode="Windows" />
<identity impersonate="true" />-->
<authentication mode="None" />
<identity impersonate="false"/>

  (3)对于rsreportserver.config文件:

将下面代码

<Authentication>
<AuthenticationTypes>
<RSWindowsNTLM/>
</AuthenticationTypes>
<RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
<RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>

  修改为

<Authentication>
<AuthenticationTypes>
<!--<RSWindowsNTLM/>-->
<Custom/>
</AuthenticationTypes>
<RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel>
<RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario>
<EnableAuthPersistence>true</EnableAuthPersistence>
</Authentication>

将下面代码

        <Security>
<Extension Name="Windows" Type="Microsoft.ReportingServices.Authorization.WindowsAuthorization, Microsoft.ReportingServices.Authorization"/>
</Security>
<Authentication>
<Extension Name="Windows" Type="Microsoft.ReportingServices.Authentication.WindowsAuthentication, Microsoft.ReportingServices.Authorization"/>
</Authentication>

修改为

<Security>
<!--<Extension Name="Windows" Type="Microsoft.ReportingServices.Authorization.WindowsAuthorization, Microsoft.ReportingServices.Authorization"/>-->
<Extension Name="None" Type="Microsoft.Samples.ReportingServices.AnonymousSecurity.Authorization, Microsoft.Samples.ReportingServices.AnonymousSecurity" />
</Security>
<Authentication>
<!--<Extension Name="Windows" Type="Microsoft.ReportingServices.Authentication.WindowsAuthentication, Microsoft.ReportingServices.Authorization"/>-->
<Extension Name="None" Type="Microsoft.Samples.ReportingServices.AnonymousSecurity.AuthenticationExtension, Microsoft.Samples.ReportingServices.AnonymousSecurity" />
</Authentication>

(4)对于rssrvpolicy.config文件,将下面代码

<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="Private_assembly"
Description="This code group grants custom code full trust. ">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="D:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin\Microsoft.Samples.ReportingServices.AnonymousSecurity.dll" />
</CodeGroup>

添加到

 <CodeGroup
class="FirstMatchCodeGroup"
version="1"
PermissionSetName="Nothing">
<IMembershipCondition
class="AllMembershipCondition"
version="1"
/>

节点里面,作为这个节点的子节点。

(5)重启SQL Server Reporting Service。

参照网址:http://blogs.msdn.com/b/jameswu/archive/2008/07/15/anonymous-access-in-sql-rs-2008.aspx

匿名访问ReportService报表服务器(一)的相关教程结束。

《匿名访问ReportService报表服务器(一).doc》

下载本文的Word格式文档,以方便收藏与打印。