【问题标题】:SSRS Report credential issueSSRS 报告凭证问题
【发布时间】:2014-01-13 07:46:05
【问题描述】:

您好,我在尝试访问报表服务器 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.SetConnectionSSLForMethod(字符串 方法名)在 Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.ProxyMethodInvocation.Execute[TReturn](RSExecutionConnection 连接,ProxyMethod1 initialMethod, ProxyMethod1 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 参数)

【问题讨论】:

    标签: reporting-services


    【解决方案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;
                }
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2014-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-11
      • 2018-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多