gpt4 book ai didi

asp.net - 使用 SSRS ASP.NET ReportViewer 和 Web 服务进行 Windows 身份验证

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

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

此站点上有一个 Web 表单 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。

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

最佳答案

我在这里遇到了自己的麻烦,但最终成功了。

机器1:客户端浏览器

机器2:网络服务器

机器3:SSRS + SQL Server

为了解决双跃点问题,我让 IT 部门为 Machine2 打开 Active Directory 委派,设置为“信任此计算机来委派任何服务(仅限 Kerberos)”。

在我的网络服务器上,我修改了 Web.config 文件:

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

在 SSRS 服务器上,我修改了 rsreportserver.config 文件,添加 <RSWindowsNegotiate/><AuthenticationTypes>部分。我相信默认值是 <RSWindowsNTLM/> 。我只是把两者都留在那里,给我:

我重新启动了 SSRS 服务器,一切都开始工作。

希望这对某人有帮助!

关于asp.net - 使用 SSRS ASP.NET ReportViewer 和 Web 服务进行 Windows 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12731078/

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