Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Friends......
starting SSRS Report Binding But Occur 401 Error
C#
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();

...............................................
CustomReportCredentials Class:
C#
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;

/// <summary>
/// Summary description for CustomReportCredentials
/// </summary>
/// [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
  
}
Posted
Updated 24-Jun-12 22:40pm
v2

 
Share this answer
 
Comments
Shingala Anil 25-Jun-12 5:47am    
Hi..bro...all thing is going well in local host but when i publish my site on test server the error is occure...i think problem is in Report Server configuration but i cant find where is actual problem in configuration please help me ....thanks
 
Share this answer
 
Comments
Shingala Anil 25-Jun-12 6:01am    
Hi..bro...all thing is going well in local host but when i publish my site on test server the error is occure...i think problem is in Report Server configuration but i cant find where is actual problem in configuration please help me ....thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900