Mar*_*sy1 4 .net security ssrs-2008 formsauthentication
我正在尝试在 SSRS 2008(不是 R2)中实现一些自定义安全代码,以允许表单身份验证而不是 Windows 身份验证。我的解决方案基于 Microsoft 示例代码,并设法使其大部分工作正常。我唯一遇到问题的地方是登录到实际的报表管理器 URL 时。
问题 1
使用 URL 时,http://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>
Run Code Online (Sandbox Code Playgroud)
我尝试更改路径以匹配 aspx 文件的确切路径,但仍然没有乐趣!
问题 2
由于上述问题,我尝试通过 URL 进入 UILogon 和 ReportManager http://localhost/Reports_MSSQL2008/Pages/UILogon.aspx。这是因为我可以进入我的自定义代码(UILogon.aspx.cs 和 IAuthorisation / IAuthentication 代码),我可以看到它执行以下操作:
问题是,当 response.redirect 返回到 GetUserInfo() 方法时,HttpContext.Current.User 为空,并且不再有 cookie。因此,返回一个空的 IIdentity(不能将它设置为其他任何东西!!)并且 SSRS 抛出错误......
Microsoft.ReportingServices.Diagnostics.Utilities.AuthenticationExtensionException:
身份验证扩展引发意外异常或返回无效值:identity==null。
有关信息 - 当我启动 Report Builder / 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>
Run Code Online (Sandbox Code Playgroud)
并且在 web.config 中只有以下内容:
<authentication mode="Forms" />
Run Code Online (Sandbox Code Playgroud)
此外,为了防止从 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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7599 次 |
| 最近记录: |