我的數據庫版本是sql server 2008 r2,系統環境是windows server2008.
對于sql server 2008 r2上報rs報表的匿名訪問問題,我這邊嘗試過兩個可行方案:
?。?)使用ReportViewer展現報表,實現ReportViewer.ReportServerCredentials 對應的接口IReportServerCredentials,在接口中指定特定的用戶名和密碼。
(2)直接訪問RS報表頁面,通過修改RS配置文件和SQL團隊技術博客所提供的認證和安全節點下擴展類。
?。?)直接訪問RS報表頁面,指定用戶名和密碼來認證(我想這個可能性也是有的,只是沒有做實驗)
兩種方案比較:
方案(1)實現起來簡單,但ReportViewer本身內存泄漏的問題,建議不要輕易嘗試,另外它不是根本上的匿名訪問,實際使用的時候需要配置用戶名和密碼。
方案(2)配置起來比較繁瑣,但卻是真正意義上的匿名訪問。
由于第二種方案能解決我現有項目的問題,所以本篇博客專注寫第二種方案的實現方式。
需要修改的配置和使用的資源:
?。?)*:/PRogram Files/Microsoft SQL Server/MSRS10_50.MSSQLSERVER/Reporting Services/ReportServer 文件夾下的web.config、rssrvpolicy.config和rsreportserver.config
?。?)*:/Program Files/Microsoft SQL Server/MSRS10_50.MSSQLSERVER/Reporting Services/ReportManager文件夾下的web.config
(3)Microsoft.Samples.ReportingServices.AnonymousSecurity.dll(微軟SQL技術博客提供的擴展類)
配置Steps:
?。?)將文件Microsoft.Samples.ReportingServices.AnonymousSecurity.dll拷貝到*:/Program Files/Microsoft SQL Server/MSRS10_50.MSSQLSERVER/Reporting Services/ReportServer/bin目錄下的。
?。?)對于上面提到的兩個web.config文件,將下面代碼
<authentication mode="Windows" /><identity impersonate="true" />
替換成
<!--<authentication mode="Windows" /> <identity impersonate="true" />--> <authentication mode="None" /> <identity impersonate="false"/>
?。?)對于rsreportserver.config文件:
將下面代碼
<Authentication> <AuthenticationTypes> <RSWindowsNTLM/> </AuthenticationTypes> <RSWindowsExtendedProtectionLevel>Off</RSWindowsExtendedProtectionLevel> <RSWindowsExtendedProtectionScenario>Proxy</RSWindowsExtendedProtectionScenario> <EnableAuthPersistence>true</EnableAuthPersistence> </Authentication>
修改為
<Authentication> <AuthenticationTypes> <!--<RSWindowsNTLM/>--> <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="Windows" Type="Microsoft.ReportingServices.Authorization.WindowsAuthorization, Microsoft.ReportingServices.Authorization"/>--> <Extension Name="None" Type="Microsoft.Samples.ReportingServices.AnonymousSecurity.Authorization, Microsoft.Samples.ReportingServices.AnonymousSecurity" /> </Security> <Authentication> <!--<Extension Name="Windows" Type="Microsoft.ReportingServices.Authentication.WindowsAuthentication, Microsoft.ReportingServices.Authorization"/>--> <Extension Name="None" Type="Microsoft.Samples.ReportingServices.AnonymousSecurity.AuthenticationExtension, Microsoft.Samples.ReportingServices.AnonymousSecurity" /> </Authentication>
(4)對于rssrvpolicy.config文件,將下面代碼
<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="D:/Program Files/Microsoft SQL Server/MSRS10_50.MSSQLSERVER/Reporting Services/ReportServer/bin/Microsoft.Samples.ReportingServices.AnonymousSecurity.dll" /> </CodeGroup>
添加到
<CodeGroup class="FirstMatchCodeGroup" version="1" PermissionSetName="Nothing"> <IMembershipCondition class="AllMembershipCondition" version="1" />
節點里面,作為這個節點的子節點。
(5)重啟SQL Server Reporting Service。
參照網址:http://blogs.msdn.com/b/jameswu/archive/2008/07/15/anonymous-access-in-sql-rs-2008.aspx
新聞熱點
疑難解答