4

我正在尝试在 SSRS 2008(不是 R2)中实现一些自定义安全代码,以允许表单身份验证而不是 Windows 身份验证。我的解决方案基于 Microsoft 示例代码,并设法让其中大部分工作正常。我唯一遇到问题的地方是登录到实际的报告管理器 URL 时。

问题 1 使用 URLhttp://localhost/Reports_MSSQL2008/时,它不会拾取UILogon.aspx我复制到/Pages文件夹中的页面(按照 Microsoft 示例的说明)。我已修改 ReportManager 文件夹中的 web.config 以包含以下内容:

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

我尝试更改路径以匹配 aspx 文件的确切路径,但仍然没有乐趣!

问题 2 由于上述问题,我尝试通过 URL 进入 UILogon 和 ReportManager http://localhost/Reports_MSSQL2008/Pages/UILogon.aspx,. 这是因为我可以进入我的自定义代码(UILogon.aspx.cs 和 IAuthorisation / IAuthentication 代码),我可以看到它执行以下操作:

  • 验证/授权用户
  • 创建 cookie
  • 将 cookie (sqlAuthCookie) 存储在响应/请求 cookie 容器中
  • 执行 response.redirect 到 /Folder.aspx 页面

问题是,当 response.redirect 回到 GetUserInfo() 方法时,HttpContext.Current.User 为空,并且不再有 cookie。因此,返回一个空的 IIdentity(不能将其设置为其他任何内容!!)并且 SSRS 抛出错误...

Microsoft.ReportingServices.Diagnostics.Utilities.AuthenticationExtensionException:
身份验证扩展引发意外异常或返回无效值:identity==null。

有关信息 - 当我启动 Report Builder / Visual Studio bi proj / Web 服务 URL 时,它完全符合我的要求并且工作正常......这只是导致问题的报告管理器。

4

1 回答 1

5

我现在已经解决了......我必须将以下内容添加到 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() 传回 null Identity,我编写了以下代码:

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;
}
于 2011-03-10T13:59:40.610 回答