2014-01-13 2 views
0

안녕하십니까. 보고서 서버 URL에 액세스하려고 할 때 다음 오류가 발생합니다. Windows 자격 증명을 ssrs 보고서에 전달하는 방법 귀하의 정보에 대해 보고서 서버는 다른 서버에서 구성되므로 로그인 인증을 요청합니다. 도와주세요. 감사합니다SSRS 보고서 자격 증명 문제

System.Net.WebException : 요청이 HTTP 상태 401 : 에 실패했습니다. Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.GetSecureMethods() 마이크로 소프트 Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.IsSecureMethod (문자열 methodName로)에서 에서. Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.ProxyMethodInvocation.Execute [TReturn (RSExecutionConnection 연결 ProxyMethod에서 Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.SetConnectionSSLForMethod (문자열 methodName로) 1 initialMethod, ProxyMethod 1 retryMethod) at Microsoft.Reporting.WebForms.Internal.Soap.ReportingServices2005.Execution.RSExecution Microsoft.Reporting.WebForms에서 Microsoft.Reporting.WebForms.ServerReport.EnsureExecutionSession()에서 Microsoft.Reporting.WebForms.SoapReportExecutionService.LoadReport에서 Connection.LoadReport (문자열 보고서, 문자열 HistoryID) (문자열 보고서, 문자열 historyId) 당신은 당신의 MyReportServerConnection 구현이이 같은입니다

ReportViewer1.ServerReport.ReportServerCredentials = new MyReportServerConnection(); 

을 설정해야

답변

0

.ServerReport.SetParameters (IEnumerable`1 매개 변수) :

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; 
      } 
     } 
    }