2012-10-04 142 views
5

我在使用SSRS时遇到了一些问题。我有一个使用Windows身份验证的ASP.NET网站。这工作正常,我知道网站当前用户是当前登录的用户。使用SSRS ASP.NET ReportViewer和Web服务进行Windows身份验证

本网站是一个webforms ReportViewer。这在我没有设置凭据时正常工作。但是,在SQL Server中查看报告的执行日志时,用户名被列为DOMAIN \ MACHINE。

我已经试过ReportServerCredentials属性设置为类似下面的类:

[Serializable] 
public class ReportCredentials : IReportServerCredentials 
{ 

    public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority) 
{ 
    authCookie = null; 
    userName = null; 
    password = null; 
    authority = null; 

    return false; 
} 

public WindowsIdentity ImpersonationUser 
{ 
    get { 
     return (WindowsIdentity)HttpContext.Current.User.Identity; 
    } 
} 

public ICredentials NetworkCredentials 
{ 
    get { 
     return null; 
    } 
} 

}

然而,当这个代码执行我现在从Web服务和报告得到了401回服务。

发生了什么事?他们都在同一个域。我想使用当前用户而不是当前机器。如果我在报告服务器上运行报告,它会在正确的用户名下列出,而不是来自我的网站。

回答

0

而不是

return (WindowsIdentity)HttpContext.Current.User.Identity; 

你可以尝试

return WindowsIdentity.GetCurrent(); 
+0

叶我想,第一,但仍然有401 :( – Lloyd

+0

其实我说了谎,一定已经被缓存,该报告目前运行,但用户名被记录为\t STAFF \ UKBRISDDWRKA424 $这是机器。哎呀。 – Lloyd

4

我在这里有自己的烦恼,但最终是成功的。

机1:客户端浏览器

机2:Web服务器

机3:SSRS + SQL服务器

为了解决双跳我对Active Directory的代表团IT部门转了机器2,设置为“信任此计算机以委派任何服务(仅Kerberos)”。

在我的web服务器我修改了Web.config文件有:

<authentication mode="Windows"/> 
<identity impersonate="true"/> 

在我修改RSReportServer.config文件中的SSRS服务器,添加<RSWindowsNegotiate/><AuthenticationTypes>部分。我相信默认是<RSWindowsNTLM/>。我刚刚离开都在那里,让我:

我重新启动SSRS服务器和所有开始工作。

希望这可以帮助别人!

相关问题