如何解决此 SSRS 身份验证异常?

发布于 2024-10-21 12:32:25 字数 1440 浏览 3 评论 0原文

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

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

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

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

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

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

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

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

有关信息 - 当我启动报表生成器/Visual Studio 双项目/Web 服务 URL 时,它完全符合我的要求并且工作正常......这只是报表管理器导致了问题。

I am trying to implement some custom security code into SSRS 2008 (not R2) to allow for Forms Authentication instead of Windows Authentication. I have based my solution on the Microsoft sample code and have managed to get most of it working absolutely fine. The only area where I'm having problems is when logging onto the actual Report Manager URL.

Issue 1
When using the URL http://localhost/Reports_MSSQL2008/ it doesn't pick up the UILogon.aspx page that i've copied into the /Pages folder (as instructed by the Microsoft example). I have amended the web.config in the ReportManager folder to contain the following:

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

I have tried changing the path to match exact path of the aspx file, but still no joy !!

Issue 2
Because of the issue above, I tried just getting into UILogon and ReportManager via the URL, http://localhost/Reports_MSSQL2008/Pages/UILogon.aspx. This works in that I get to step into my custom code (UILogon.aspx.cs and IAuthorisation / IAuthentication code) and I can see it doing the following:

  • authenticating / authorising the user
  • creating the cookie
  • storing the cookie (sqlAuthCookie) on the response / request cookie container
  • performing the response.redirect to the /Folder.aspx page

Problem is, when the response.redirect comes back into the GetUserInfo() method, the HttpContext.Current.User is null, and there is no cookie anymore. Because of this, a null IIdentity is returned (cant set it to anything else !!) and SSRS throws the error...

Microsoft.ReportingServices.Diagnostics.Utilities.AuthenticationExtensionException:
The Authentication Extension threw an unexpected exception or returned a value that is not valid: identity==null.

For info - when I launch Report Builder / Visual Studio bi proj / the Web Service URL it does exactly what I require and works fine......it's just the Report Manager thats causing the problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抚笙 2024-10-28 12:32:25

我现在已经解决了它......我必须将以下内容添加到 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;
}

I have now resolved it....I had to add the following to the rsreportserver.config:

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

and only have the following in the web.config:

<authentication mode="Forms" />

Also, to safe-guard against a null Identity being passed back from GetUserInfo(), I coded the following:

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文