C# SSRS表单身份验证-如何将Cookie凭据传递到报表服务器

C# SSRS表单身份验证-如何将Cookie凭据传递到报表服务器,c#,reporting-services,forms-authentication,reporting-services-2016,C#,Reporting Services,Forms Authentication,Reporting Services 2016,我目前正在尝试使用表单身份验证在web应用程序中呈现SSRS报告 我的SSRS报告版本是2016年 起初,我的印象是网络凭据可以工作,在遇到错误后,我发现我们需要使用FormsAuthentication,通过传递cookie来验证用户 我已按照以下链接中的指南对报表服务器中的配置文件进行了必要的设置:- reporting services在localhost/ReportServer和上按预期工作 SSRS门户,localhost/Reports。我也能够访问所述服务器 远地 下面是我用来

我目前正在尝试使用表单身份验证在web应用程序中呈现SSRS报告

我的SSRS报告版本是2016年

起初,我的印象是网络凭据可以工作,在遇到错误后,我发现我们需要使用FormsAuthentication,通过传递cookie来验证用户

我已按照以下链接中的指南对报表服务器中的配置文件进行了必要的设置:-

reporting services在localhost/ReportServer和上按预期工作 SSRS门户,localhost/Reports。我也能够访问所述服务器 远地

下面是我用来获取经过身份验证的cookie的代码

MyReportingService rsClient = new MyReportingService();
rsClient.Url = "http://xxx.xxx.xxx.xxx/reportserver/ReportService2010.asmx";
try
{
     rsClient.LogonUser("user", "password", "");
     Cookie myAuthCookie = rsClient.AuthCookie;
     HttpCookie cookie = new HttpCookie(myAuthCookie.Name, myAuthCookie.Value);
     Response.Cookies.Add(cookie);
}
据推测,这将用于验证用户的身份

Cookie authCookie = new Cookie(cookie2.Name, cookie2.Value);

authCookie.Domain = "DomainName";

rvSiteMapping.ServerReport.ReportServerCredentials = new MyReportServerCredentials(authCookie);

rvSiteMapping.ServerReport.Cookies.Add(authCookie);
在我的表单中,在IReportsServerCredentials类中进行身份验证:-

public bool GetFormsCredentials(out Cookie authCookie,
            out string user, out string password, out string authority)
        {
            authCookie = m_authCookie;
            user = password = authority = null;
            return true;  // Use forms credentials to authenticate.
        }
我遇到的问题是应用程序将凭据传递到报表服务器时。我相信我一定是做得不对,因为虽然我的应用程序确实获得了cookie,但当它验证cookie提供的凭据时,我收到了text/html错误:-

Object moved to <a href="/ReportServer/logon.aspx?ReturnUrl=%2fReportserver%2fReportExecution2005.asmx" />
我试过用谷歌搜索答案,但大多数结果都是针对你的 windows身份验证和少数与窗体身份验证相关的身份验证
与我提到的代码非常相似。

问题的根本原因一直在我的眼皮底下

域名应指的是web域,而不是active directory域

authCookie.Domain = "DomainName";
cookie现在能够按照预期对用户进行身份验证

希望这能帮助那些碰巧犯同样错误的人

authCookie.Domain = "DomainName";