2011-03-10 34 views
4

我想實現一些自定義安全代碼到SSRS 2008(不是R2),以允許窗體身份驗證,而不是Windows身份驗證。我將我的解決方案基於Microsoft示例代碼,並設法使其大部分工作得非常好。我唯一遇到問題的地方是登錄到實際的報告管理器URL。如何解決此SSRS身份驗證異常?

問題1 當使用URL http://localhost/Reports_MSSQL2008/它不拿起UILogon.aspx頁,我已經複製到/Pages文件夾(在Microsoft例如,作爲指導下使用)。我已經修改了web.config文件中ReportManager文件夾包含以下內容:

<authentication mode="Forms"> 
    <forms loginUrl="UILogon.aspx" 
     name="sqlAuthCookie" 
     timeout="60" 
     slidingExpiration="true" 
     path="/" /> 
</authentication> 

我試圖改變路徑,以匹配aspx文件的確切路徑,但仍然沒有喜悅!

第2期 由於上述問題的,我試過剛剛進入UILogon和ReportManager通過URL,http://localhost/Reports_MSSQL2008/Pages/UILogon.aspx。這工作,因爲我可以踏進我的自定義代碼(UILogon.aspx.cs和IAuthorisation/IAuthentication代碼),我可以看到它執行以下操作:

  • 認證/授權用戶
  • 創建的cookie
  • 存儲所述響應/請求的cookie容器
  • 執行的Response.Redirect到/Folder.aspx頁

問題是,在該cookie(sqlAuthCookie)時的Response.Redirect COM回到GetUserInfo()方法,HttpContext.Current.User爲空,並且不再有cookie。正因爲如此,則返回一個空的IIdentity(不能將它設置爲別的!!)和SSRS引發錯誤...

Microsoft.ReportingServices.Diagnostics.Utilities.AuthenticationExtensionException:
的認證擴展拋出意外的異常或返回無效的值:identity == null。

有關信息 - 當我啓動Report Builder/Visual Studio bi proj/Web Service URL時,它完全符合我的要求並且工作正常......只是報告管理器導致問題。

+0

微軟sa用於設置這個? – BSick7 2011-05-17 14:00:29

+0

使用此鏈接 - http://www.devx.com/dotnet/Article/26759/0/page/1迄今爲止我發現的最好的例子。在http://www.devx.com/dotnet/Article/27133上也有一部分內容 – Markleesy1 2011-07-12 10:57:23

回答

4

我現在已經解決了它....我不得不添加以下到rsreportserver.config:

<UI> 
    <CustomAuthenticationUI> 
     <loginUrl>/Pages/UILogon.aspx</loginUrl> 
    <UseSSL>false</UseSSL> 
    </CustomAuthenticationUI> 
    <ReportServerUrl></ReportServerUrl> 
    <PageCountMode>Estimate</PageCountMode> 
</UI> 

,並只有在web.config中的以下內容:

<authentication mode="Forms" /> 

此外,爲了安全防範從GetUserInfo()傳回的空身份,我編碼如下:

public void GetUserInfo(out IIdentity userIdentity, out IntPtr userId) 
{ 
    //default the userIdentity 
    userIdentity = new GenericIdentity(WindowsIdentity.GetCurrent().Name); 

    // If the current user identity is not null, 
    // set the userIdentity parameter to that of the current user 
    if (HttpContext.Current != null 
      && HttpContext.Current.User != null) 
    { 
     userIdentity = HttpContext.Current.User.Identity; 
    } 

    // initialize a pointer to the current user id to zero 
    userId = IntPtr.Zero; 
} 
相關問題