SSRS 实现匿名远程访问

首先,匿名访问是MS NOT RECOMMAND的。人家说了,DO NOT USE ANONYMOUS AUTH!NEVER USE IT IN PRODUCTION ENVIRONMENT!但是他也说了,你非要用,也不是不行。

然后,声明一下,方法和代码都不是原创,你可以选择查看原文

 

最后,开始正题。

由于项目需要临时匿名访问SSRS报表。项目老大让我学习。网上已经有很多这方面的文章了,但通常都不是图文并茂,而且为了备忘,我决定自己写一篇。

首先,你需要在我的腾讯微云下载一个实现匿名访问的dll。当然,你也可以选择百度一下,名字就叫Microsoft.Samples.ReportingServices.AnonymousSecurity.dll,不过我的这个亲测可用而且无毒无害哈哈。如果更喜欢折腾,你甚至可以到文章最开始的那个链接的博客里复制该dll的源码自己compile一个也没有任何问题,不过我需要提醒你,你的Class Library需要基于.net 2.0,而且命名什么的最好都保持一致否则下面需要修改。

下载好了,or,compile好了,非常好,把它拿到对应的路径下:一般是这个目录(C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin)。这一这里名字都需要保持是Microsoft.Samples.ReportingServices.AnonymousSecurity不能变,因为后面要用到。可以用其他的吗?答案是YES,不过还是那句话,取决于你是否喜欢折腾。

下一步。VERY IMPORTANT!!!!!备份好(C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportManager)目录下的web.config,(C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer)目录下的rsreportserver.configrssrvpolicy.configweb.config。这里提醒你了,你不干我也不敢保证一定出问题。

下一步。O对了,推荐使用强大的VS编辑,你要是喜欢用notepad那我也没办法。

打开ReportManager目录下的web.config,把

<authentication mode="None" />
    <identity impersonate="false" />

替换为截图所示。

接下来切换到ReportServer目录,对web.config做同样的操作。

 

next,打开同样目录下的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 group grants custom code full trust. ">
              <IMembershipCondition
                      class="UrlMembershipCondition"
                      version="1"
                      Url="C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer\bin\Microsoft.Samples.ReportingServices.AnonymousSecurity.dll"
                                />
            </CodeGroup>

注意这里的Url路径取决于你的。最终效果应该如下图

next,打开同样目录下的rsreportserver.config,定位到

<Authentication>
        <AuthenticationTypes>
            <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>

OK, 结束了done。

last step,最保险的措施,推荐重启一下电脑。当然也可以先重启一下SSRS服务。然后访应该是没有问题了。

 

But,我就是仅仅重启了SSRS服务出现了下面这个NB的让我花了4个多小时的问题:

最后你猜怎么着,上管理器看日志,发现了这个奇葩的问题

忍不住f*ck了一句,查看文件属性发现不是权限问题。那么,有一种可能是,TMD这玩意被另一个进程占着了,接下来果断重启啊,如你所料,reboot后解决,本地访问OK,远程访问OK,实现了匿名访问。

 

[以上有错欢迎指正]

posted @ 2015-12-17 23:23  i951116  阅读(3151)  评论(0编辑  收藏  举报