ReportViewer : Access Remote Server Report with Credentials Sep 09, 2011

If you want to work with remote SSRS report while debugging your application you would want to authenticate with the remote server, you cannot use impersonation as this would actually make the entire application run under impersonation so to solve this we can use impersonation for the report viewer only to do this :

#if (DEBUG)
this.ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerCredentials("username", "password","domain");

and a ReportServerCredentials class

public class ReportServerCredentials : IReportServerCredentials
        private string _userName;
        private string _password;
        private string _domain;

        public ReportServerCredentials(string userName, string password, string domain)
            _userName = userName;
            _password = password;
            _domain = domain;

        public System.Security.Principal.WindowsIdentity ImpersonationUser
            get { return null; }

        public System.Net.ICredentials NetworkCredentials
            get { return new System.Net.NetworkCredential(_userName, _password, _domain); }

        bool IReportServerCredentials.GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
            authCookie = null;
            userName = _userName;
            password = _password
            authority = _domain;
            return false;