gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 19:14:26 26 4
gpt4 key购买 nike

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

问题 1使用 URL http://localhost/Reports_MSSQL2008/ 时,它不会获取我复制到 /Pages< 中的 UILogon.aspx 页面 文件夹(按照 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) 存储在响应/请求 cookie 容器中
  • 执行到/Folder.aspx 页面的response.redirect

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

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

仅供引用 - 当我启动报表生成器/Visual Studio bi proj/Web 服务 URL 时,它完全符合我的要求并且工作正常......这只是报表管理器导致了问题。

最佳答案

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

关于.net - 如何解决此 SSRS 身份验证异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5258259/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com