zoukankan      html  css  js  c++  java
  • Microsoft SQL SERVER 2008 R2 REPORT SERVICE 匿名登录(转)

    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.WindowsAuthoriz
    ation,
    Microsoft.ReportingServices.Authorization"/>
    </Security>
    <Authentication>
       <Extension Name="Windows"
    Type="Microsoft.ReportingServices.Authentication.WindowsAuthent
    ication,
    Microsoft.ReportingServices.Authorization"/>
    </Authentication>

    将其改为

    <Security>   <Extension Name="None"
    Type="Microsoft.Samples.ReportingServices.AnonymousSecurity.Author
    ization,
    Microsoft.Samples.ReportingServices.AnonymousSecurity"/>
    </Security>
    <Authentication>
       <Extension Name="None"
    Type="Microsoft.Samples.ReportingServices.AnonymousSecurity.Authen
    ticationExtension,
    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>


    到此为止,我们匿名登录的方式,配置工作就完成了,下面我将在配置完成后访问报表时,出现的几种错误的解决方法说明一下。
    1、在访问报表时,“出现数据源访问失败,提示,数据源是windows验证,而报表服务器禁止了windows验证。或使用特定用户认证”,这种错误,很明显是你的数据源设置的验证方式不对,打开你的数据源,选择“凭证”,选择“不使用凭证”。
    注:如果你使用的数据集为Cube,在配置数据源时必须使用http的方式连接。

    2、当我们修改了数据源不使用凭据后,我们需要给报表制定一个默认的执行账户,打开SSRS的配置管理,选择执行账户,设置一个系统中的账户,输入密码即可。

    以上就是SSRS匿名登录的全部过程,如有更好的方法,我们可以共同交流,有不对的地方,请大家多多指教
  • 相关阅读:
    java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized...
    Spring Security 自定义 登陆 权限验证
    springboot中使用spring security,登录url就出现403错误
    RocketMQ最佳实践
    JS 中获取服务器时间的注意点
    许小年:中国经济刚入寒冬,四万亿也救不了
    RestTemplate发送GET请求
    String类的format方法的用法
    参数的打包和解包实例
    16.return 返回值
  • 原文地址:https://www.cnblogs.com/timy/p/2418269.html
Copyright © 2011-2022 走看看