適用於:SQL Server 2016 (13.x) Reporting Services 和更新版本
Power BI 報表伺服器
Reporting Services 2016 推出新的入口網站,以裝載新的 OData API,同時也裝載新的報表工作負載,例如行動報表和 KPI。 這個新的入口網站依賴較新的技術,並透過在稱為 Microsoft.ReportingServices.Portal.WebHost.exe 的個別處理序中執行,來與熟悉的 ReportingServicesService.exe 隔離。 此處理序不是 ASP.NET 託管應用程式,因此會破壞現有自訂安全性延伸模組的假設。 此外,自訂安全性延伸模組的目前介面不允許傳入任何外部內容,讓實作者只能選擇檢查已知的全域 ASP.NET 物件。 由於 Microsoft.ReportingServices.Portal.WebHost.exe 處理序不是 ASP.NET 託管應用程式,因此需要對介面進行一些變更。
變更的項目為何?
引進了可透過 IRSRequestContext 實作的新介面,提供延伸模組更常用的屬性來做出與驗證相關的決定。
在舊版中,報表管理員位於前端,並可使用自己的自訂登入頁面進行設定。 在 Reporting Services 2016 中,只支援一個 reportserver 裝載的頁面,但兩個應用程式都應該驗證。
實作
在舊版中,延伸模組只能依賴 ASP.NET 物件應該就緒的常見假設。 由於新的入口網站不會在 ASP.NET 中執行,因此延伸模組可能會引發物件為 NULL 的問題。
最泛型的範例是存取 HttpContext.Current
讀取要求資訊,例如標頭和 Cookie。 為了讓延伸模組做出相同的決定,我們在延伸模組中引進了提供要求資訊的新方法,並在從入口網站進行驗證時予以呼叫。
自訂延伸模組必須實作 IAuthenticationExtension2 介面,才能使用這個新的介面。 擴充功能需要實作這兩個方法版本 GetUserInfo ,因為 reportserver 內容和 Microsoft.ReportingServices.Portal.WebHost.exe 程式中所使用的其他版本會呼叫。 下列範例示範其中一個簡單的入口網站實作,使用由 reportserver 解析的識別。
public void GetUserInfo(IRSRequestContext requestContext, out IIdentity userIdentity, out IntPtr userId)
{
userIdentity = null;
if (requestContext.User != null)
{
userIdentity = requestContext.User;
}
// initialize a pointer to the current user ID to zero
userId = IntPtr.Zero;
}
部署和設定
自訂安全性延伸模組所需的基本設定與舊版相同。 web.config 和 rsreportserver.config 需要變更:如需詳細資訊,請參閱 在報表伺服器上設定自定義或窗體驗證。
報表管理員不再有個別的 web.config,入口網站會繼承與 reportserver 端點相同的設定。
電腦金鑰
在需要解密驗證 Cookie 的表單驗證案例中,兩個處理序都需要使用相同的電腦金鑰和解密演算法設定。 先前設定 Reporting Services 以處理向外延展環境的使用者很熟悉此步驟,但現在即使是在單一計算機上部署也是必要條件。
您應該使用專屬於您部署的驗證金鑰,有數種工具可以產生金鑰,例如網際網路資訊服務管理員 (IIS)。 網際網路上可以找到其他工具。
適用於: SQL Server Reporting Services (2017 與更新版本)
Power BI 報表伺服器
\ReportServer\RSReportServer.config
開啟 RSReportServer.config 檔案,並在 <Configuration>
區段中貼上您產生的 <machineKey>
元素。 根據預設,RSReportServer.config 檔案位於 \Program Files\Microsoft SQL Server Reporting Services\SSRS\ReportServer\RSReportServer.config
Reporting Services 和 \Program Files\Microsoft Power BI Report Server\PBIRS\ReportServer\RSReportServer.config
Power BI 報表伺服器。
<MachineKey ValidationKey="[YOUR KEY]" DecryptionKey=="[YOUR KEY]" Validation="AES" Decryption="AES" />
適用於:SQL Server Reporting Services (2016)
\ReportServer\web.config
開啟 ReportServer 的 web.config 檔案,並在 <system.web>
區段中貼上您產生的 <machineKey>
元素。 根據預設,Web.config 檔案位於 \Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\web.config。
<machineKey validationKey="[YOUR KEY]" decryptionKey=="[YOUR KEY]" validation="AES" decryption="AES" />
\RSWebApp\Microsoft.ReportingServices.Portal.exe.config
開啟 RSWebApp 的 Microsoft.ReportingServices.Portal.WebHost.exe.config 檔案,並在 <configuration>
區段中貼上您產生的 <system.web>
和 <machineKey>
元素。 根據預設,Microsoft.ReportingServices.Portal.WebHost.exe.config 檔案位於 \Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\RSWebApp\Microsoft.ReportingServices.Portal.WebHost.exe.config。
<system.web>
<machineKey validationKey=="[YOUR KEY]" decryptionKey=="[YOUR KEY]" validation="AES" decryption="AES" />
</system.web>
設定傳遞 Cookie
新入口網站和 reportserver 的通訊使用某些作業的內部 SOAP API (類似於舊版的報表管理員)。 當需要更多 Cookie 才能從入口網站傳遞至 reportserver 時,可以使用 PassThroughCookies 屬性。 如需詳細資訊,請參閱 設定入口網站以傳遞自定義驗證 Cookie。
<UI>
<CustomAuthenticationUI>
<PassThroughCookies>
<PassThroughCookie>sqlAuthCookie</PassThroughCookie>
</PassThroughCookies>
</CustomAuthenticationUI>
</UI>