Reporting services SSRS报告凭证问题
您好,我在尝试访问报表服务器url时遇到以下错误。如何将windows凭据传递到ssrs报告。对于您的信息,报表服务器是在不同的服务器中配置的,因此它将要求进行登录验证。请帮忙。谢谢 System.Net.WebException:请求失败,HTTP状态为401: 未经授权。在 Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.GetSecureMethods() 在 Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.IsSecureMethod(字符串 方法名称)在 Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.SetConnectionsLformMethod(字符串 方法名称)在 Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.ProxyMethodInvocation.Execute[TReturn](RSExecutionConnection 连接,ProxyMethodReporting services SSRS报告凭证问题,reporting-services,Reporting Services,您好,我在尝试访问报表服务器url时遇到以下错误。如何将windows凭据传递到ssrs报告。对于您的信息,报表服务器是在不同的服务器中配置的,因此它将要求进行登录验证。请帮忙。谢谢 System.Net.WebException:请求失败,HTTP状态为401: 未经授权。在 Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.GetSecureMeth
1 initialMethod,ProxyMethod
1 retryMethod)位于
Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.LoadReport(字符串
报告,字符串HistoryID)位于
Microsoft.Reporting.WebForms.SoapReportExecutionService.LoadReport(字符串
报告,字符串historyId)位于
Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession()位于
Microsoft.Reporting.WebForms.ServerReport.SetParameters(IEnumerable`1
参数)
你需要设置
ReportViewer1.ServerReport.ReportServerCredentials = new MyReportServerConnection();
您的MyReportServerConnection
实现如下:
private sealed class MyReportServerConnection : IReportServerConnection2
{
[System.Runtime.InteropServices.DllImport("advapi32.dll", SetLastError = true)]
public static extern bool LogonUser(
string lpszUsername,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
out IntPtr phToken);
public WindowsIdentity ImpersonationUser
{
get
{
// Use credentials from config file
IntPtr userToken = IntPtr.Zero;
bool success = LogonUser(
"reportusername",
"reportuserdomain",
"reportuserpassword",
9,//LOGON_TYPE_NEW_CREDENTIALS
3,//LOGON32_PROVIDER_WINNT50
out userToken);
if (!success)
{
throw new Exception("Logon user failed");
}
return new WindowsIdentity(userToken);
}
}
public ICredentials NetworkCredentials
{
get
{
return null;
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
{
authCookie = null;
userName = null;
password = null;
authority = null;
// Not using form credentials
return false;
}
public Uri ReportServerUrl
{
get
{
return new Uri("http://reportserverurl/ReportServer");
}
}
public int Timeout
{
get
{
return 60000; // 60 seconds
}
}
public IEnumerable<Cookie> Cookies
{
get
{
// No custom cookies
return null;
}
}
public IEnumerable<string> Headers
{
get
{
// No custom headers
return null;
}
}
}
私有密封类MyReportServerConnection:IReportServerConnection2
{
[System.Runtime.InteropServices.DllImport(“advapi32.dll”,SetLastError=true)]
公共静态外部bool LogonUser(
字符串lpszUsername,
字符串lpszDomain,
字符串lpszPassword,
int dwLogonType,
int dwLogonProvider,
out IntPtr phToken);
公共WindowsIdentity模拟用户
{
收到
{
//使用配置文件中的凭据
IntPtr userToken=IntPtr.Zero;
bool success=LogonUser(
“报告用户名”,
“reportuserdomain”,
“reportuserpassword”,
9,//登录\u类型\u新\u凭证
3,//LOGON32\u提供程序\u WINNT50
输出用户令牌);
如果(!成功)
{
抛出新异常(“登录用户失败”);
}
返回新的WindowsIdentity(userToken);
}
}
公共ICredentials网络凭据
{
收到
{
返回null;
}
}
public bool GetFormsCredentials(out Cookie authCookie、out string用户名、out string密码、out string权限)
{
authCookie=null;
用户名=null;
密码=null;
权限=空;
//不使用表单凭据
返回false;
}
公共Uri ReportServerUrl
{
收到
{
返回新的Uri(“http://reportserverurl/ReportServer");
}
}
公共整数超时
{
收到
{
返回60000;//60秒
}
}
公共数字饼干
{
收到
{
//没有定制的饼干
返回null;
}
}
公共IEnumerable标头
{
收到
{
//没有自定义标题
返回null;
}
}
}