[转]Microsoft SQL SERVER 2008 R2 REPORT SERVICE 匿名登录

本文转自:https://www.cnblogs.com/Zouzhe/p/5736070.html

SQL SERVER 2008 R2 是微软目前最新的数据库版本,在之前的SQL SERVER 2005中,我们可以通过修改IIS对应的SSRS站点及SSRS的配置文件,将SSRS配置成匿名登录的方式,把报表集成到系统中,而现在SSRS2008 R2已经和IIS完全分离,所以说我们在沿用2005的配置方法是不可行的,为了让大家能够更好的了解,下面将先给大家简单介绍一下我在开发过程中,遇到的集成SSRS报表的场景。不同的集成有不同的解决方案。

 
1、ASP.net中集成SSRS的报表,这种集成方式,我们一般采用的方法是使用Report viewer控件展示报表,在这种情况下,如果,我们不做任何的处理,客户端在访问我们的报表时会提示window身份验证的输入框,我们只有输入用户名和密码才能正常的访问报表,在这种场景下,如果,我们想去掉windows的验证框,我们可以实现SSRS的一个接口(IReportServerCredential),该接口提供报表的三种身份验证方式(WindowsCredential、NetWorkCrendtial、FormCredential),而我们要使用的就是第二种身份验证方式。我们需要实现接口中的方法,new NetWorkCredential(username,password,domain)然后将Report Viewer的Credential属性设置成我们实现接口类的对象,这样就间接的实现了我们的报表匿名登录。
 
当然,在第一种场景中,我们也可以使用SSRS的webservice,目前webservice的版本有2005、2010两个版本,直接将webservice添加引用即可(http://hostname:port/reportserver/reportservice2005.asmx或reportservice2010.asmx),这里就不详细说了。
 
2、第二种方式是在sharepoint中集成SSRS报表,这种方式,我们一般采用部署的方式,就可以解决SSRS访问权限的问题,我们一般采用将SSRS安装成,sharepoint集成模式的安装方式,这样SSRS就会继承sharepoint的权限管理,我们要做的就是做好sharepoint的权限控管就可以了。
 
 
3、第三种方式,也是我们今天着重要推荐的方式,是通过修改配置文件,以及添加程序集的方式,实现SSRS真正意义上的匿名登录。下面我把步骤介绍给大家。
 
  3(1)、首先我们找到SSRS安装目录下的两个web.config配置文件,默认安装目录分别是(C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer和C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportManager),然后,找到两个配置文件中的
<authentication mode="windows" />      
<identity impersonate="true" />
 
将其改为
<authentication mode="None"/>  
<identity impersonate="false" />
 
 3(2)、找到(C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer)目录下的rsreportserver.config文件,找到配置文件中的
 
<Authentication> <AuthenticationTypes> <RSWindowsNegotiate/> <RSWindowsNTLM/> </AuthenticationTypes> <RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel> <RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario> <EnableAuthPersistence>true</EnableAuthPersistence> </Authentication>
 
将其改为
<Authentication> <AuthenticationTypes> <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="None" Type="Microsoft.Samples.ReportingServices.AnonymousSecurity.Authorization, Microsoft.Samples.ReportingServices.AnonymousSecurity"/> </Security> <Authentication>   <Extension Name="None" Type="Microsoft.Samples.ReportingServices.AnonymousSecurity.AuthenticationExtension, Microsoft.Samples.ReportingServices.AnonymousSecurity"/> </Authentication>
 
从上边两个节点中我们可以看出,我们需要引用一个dll文件,就是Microsoft.Samples.ReportingServices.AnonymousSecurity.dll,我们需要将这个dll放入到(C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin)目录下。
 
  3(3)、在将dll放入到目录以后,我们来继续修改我们的配置文件,在(C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer)目录下,找到rssrvpolicy.config
找到
<CodeGroup class="FirstMatchCodeGroup" version="1" PermissionSetName="Nothing"> <IMembershipCondition class="AllMembershipCondition" version="1" />
在其下边追加如下节点(红色部分,按照你的实际路径而定)
 
<CodeGroup class="UnionCodeGroup"  version="1"                                                              PermissionSetName="FullTrust"  Name="Private_assembly" Description="This code grou p grants custom code full trust.">                            
<IMembershipCondition class="UrlMembershipCondition"       
version="1"  Url="C:\Program Files\Microsoft SQL

Server\MSRS10_50.MSSQLSERVER2008\Reporting Services\ReportServer\bin\Microsoft.Samples.ReportingServices.AnonymousSecurity.dll" />

       </CodeGroup>

 
到此为止,我们匿名登录的方式,配置工作就完成了,下面我将在配置完成后访问报表时,出现的几种错误的解决方法说明一下。
 
博客原文:http://blog.sina.com.cn/s/blog_7778950d0100qa61.html 
 

猜你喜欢

转载自www.cnblogs.com/freeliver54/p/9044312.html