title: Calling SSRS Report From Asp.net Pages
body: <pre><code>        ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
          ReportViewer1.ServerReport.ReportServerUrl = new Uri(Keys.ReportServerUrl);
          ReportViewer1.ServerReport.ReportPath = Keys.ReportPath + "RptTest";
  
          ReportViewer1.ShowParameterPrompts = false;
          ReportViewer1.ShowCredentialPrompts = false;
          IReportServerCredentials irsc = new CustomReportCredentials();
          ReportViewer1.ServerReport.ReportServerCredentials = irsc;
          ReportViewer1.ServerReport.Refresh();
  </code></pre>
  
  <p>...............................................
  CustomReportCredentials Class:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net;
  using System.Security.Principal;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using Utilities;
  
  
  /// &lt;summary&gt;
  /// Summary description for CustomReportCredentials
  /// &lt;/summary&gt;
  /// [Serializable]
  public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
  {
  
  
      private string _UserName;
      private string _PassWord;
      private string _DomainName;
  
      #region IReportServerCredentials Members
      public CustomReportCredentials()
      {
          _UserName = "";
          _PassWord = "";
          _DomainName = "";
      }
  
      public bool GetFormsCredentials(out System.Net.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
              {
  
                  System.Security.Principal.WindowsImpersonationContext impersonationContext = null;
                  System.Security.Principal.WindowsIdentity currentWindowsIdentity = null;
                              currentWindowsIdentity = (System.Security.Principal.WindowsIdentity)System.Web.HttpContext.Current.User.Identity;
                  impersonationContext = currentWindowsIdentity.Impersonate();
  
                  //Insert your code that runs under the security context of the authenticating user here.
  
                  impersonationContext.Undo();
  
                  return currentWindowsIdentity; // not use ImpersonationUser
                  }
      }
  
      public System.Net.ICredentials NetworkCredentials
      {
        get
        {
          string userName = "";
          string domainName = "";
          string password = "";
  
          return new System.Net.NetworkCredential(userName, password, domainName);
        }
      }
  
      #endregion
  
  }
  </code></pre>