2011-03-10 33 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; 
} 
相关问题