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,實現了匿名訪問。

 

[以上有錯歡迎指正]


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM