The permissions granted to user ' are insufficient for performing this operation. (rsAccessDenied)"}

前端 未结 21 1209
暖寄归人
暖寄归人 2020-12-04 08:34

I created a report model using SSRS (2005) and published to the local server. But when I tried to run the report for the model I published using report builder I get the fol

21条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 09:31

    I know it's for a long time ago but may be helpful to any other new comers,

    I decided to pass user name,password and domain while requesting SSRS reports, so I created one class which implements IReportServerCredentials.

     public class ReportServerCredentials : IReportServerCredentials   
    {
        #region  Class Members
            private string username;
            private string password;
            private string domain;
        #endregion
    
        #region Constructor
            public ReportServerCredentials()
            {}
            public ReportServerCredentials(string username)
            {
                this.Username = username;
            }
            public ReportServerCredentials(string username, string password)
            {
                this.Username = username;
                this.Password = password;
            }
            public ReportServerCredentials(string username, string password, string domain)
            {
                this.Username = username;
                this.Password = password;
                this.Domain = domain;
            }
        #endregion
    
        #region Properties
            public string Username
            {
                get { return this.username; }
                set { this.username = value; }
            }
            public string Password
            {
                get { return this.password; }
                set { this.password = value; }
            }
            public string Domain
            {
                get { return this.domain; }
                set { this.domain = value; }
            }
            public WindowsIdentity ImpersonationUser
            {
                get { return null; }
            }
            public ICredentials NetworkCredentials
            {
                get
                {
                    return new NetworkCredential(Username, Password, Domain);
                }
            }
        #endregion
    
        bool IReportServerCredentials.GetFormsCredentials(out System.Net.Cookie authCookie, out string userName, out string password, out string authority)
        {
            authCookie = null;
            userName = password = authority = null;
            return false;
        }
    }
    

    while calling SSRS Reprots, put following piece of code

     ReportViewer rptViewer = new ReportViewer();
     string RptUserName = Convert.ToString(ConfigurationManager.AppSettings["SSRSReportUser"]);
            string RptUserPassword = Convert.ToString(ConfigurationManager.AppSettings["SSRSReportUserPassword"]);
            string RptUserDomain = Convert.ToString(ConfigurationManager.AppSettings["SSRSReportUserDomain"]);
            string SSRSReportURL = Convert.ToString(ConfigurationManager.AppSettings["SSRSReportURL"]);
            string SSRSReportFolder = Convert.ToString(ConfigurationManager.AppSettings["SSRSReportFolder"]);
    
            IReportServerCredentials reportCredentials = new ReportServerCredentials(RptUserName, RptUserPassword, RptUserDomain);
            rptViewer.ServerReport.ReportServerCredentials = reportCredentials;
            rptViewer.ServerReport.ReportServerUrl = new Uri(SSRSReportURL);
    

    SSRSReportUser,SSRSReportUserPassword,SSRSReportUserDomain,SSRSReportFolder are defined in web.config files.

提交回复
热议问题