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真正意义上的匿名登录。下面我把步骤介绍给大家。
<authenticationmode="windows"/>
<identityimpersonate="true"/>
将其改为
<authenticationmode="None"/>
<identityimpersonate="false" />
<Authentication>
<AuthenticationTypes>
<RSWindowsNegotiate/>
<RSWindowsNTLM/>
</AuthenticationTypes>
<RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel><RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario><EnableAuthPersistence>true</EnableAuthPersistence></Authentication>
<AuthenticationTypes>
<RSWindowsNegotiate/>
<RSWindowsNTLM/>
</AuthenticationTypes>
<RSWindowsExtendedProtect
将其改为
<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
FilesMicrosoft SQL ServerMSRS10_50.MSSQLSERVERReporting ServicesReportServerin)目录下。
找到
<CodeGroupclass="FirstMatchCodeGroup" version="1"
PermissionSetName="Nothing">
<IMembershipCondition class="AllMembershipCondition"
version="1" />
PermissionSetName="Nothing">
<IMembershipCondition class="AllMembershipCondition"
version="1" />
在其下边追加如下节点(红色部分,按照你的实际路径而定)
<CodeGroup
class="UnionCodeGroup" version="1" PermissionSetName="FullTrust"
Name="Private_assembly" Description="Thiscode
grou p grants customcode fulltrust.">
<IMembershipCondition class="UrlMembershipCondition"
version="1" Url="C:ProgramFilesMicrosoft SQL
ServerMSRS10_50.MSSQLSERVER2008ReportingServicesReportServerinMicrosoft.Samples.ReportingServices.AnonymousSecurity.dll"/>
到此为止,我们匿名登录的方式,配置工作就完成了,下面我将在配置完成后访问报表时,出现的几种错误的解决方法说明一下。
1、在访问报表时,“出现数据源访问失败,提示,数据源是windows验证,而报表服务器禁止了windows验证。或使用特定用户认证”,这种错误,很明显是你的数据源设置的验证方式不对,打开你的数据源,选择“凭证”,选择“不使用凭证”。点击确定即可。如图:
注:如果你使用的数据集为Cube,在配置数据源时必须使用http的方式连接。
2、当我们修改了数据源不使用凭据后,我们需要给报表制定一个默认的执行账户,打开SSRS的配置管理,选择执行账户,设置一个系统中的账户,输入密码即可。如图:
以上就是SSRS匿名登录的全部过程。