开发者

reporting service network credentials

receiving the error:

"Property or indexer 'Microsoft.Reporting.WebForms.IReportServerCredentials.NetworkCredentials' cannot be assigned to-- it is read only"

within this line:

reportviewer1.ServerReport.ReportServerCredentials.NetworkCredentials = new System.Net.NetworkCredential("somea开发者_如何学Goccount", "somepassword");

When I hover the cursor on NetworkCredentials, it says: "Gets or sets the network credentials that are used for authentication with report server"..

what the heck is going on here?

thanks


this.rpv.ServerReport.ReportServerCredentials is not read-only. Read this post:

http://www.visualstudiodev.com/visual-studio-report-controls/reportviewerserverreportreportservercredentialsnetworkcredentials-readonly-24629.shtml


it is still read only, that ReportServerCredentials field is still read only, it has only getter but not a setter !


add this class to the same namespace:

 public class CustomReportCredentials : IReportServerCredentials
 {
     private string _UserName;
     private string _PassWord;
     private string _DomainName;

 public CustomReportCredentials(string UserName, string PassWord, string DomainName)
     {
        _UserName = UserName;
        _PassWord = PassWord;
        _DomainName = DomainName;
     }

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

     public ICredentials NetworkCredentials
     {
        get { return new NetworkCredential(_UserName, _PassWord, _DomainName); }
     }

      public bool GetFormsCredentials(out Cookie authCookie, out string user,
      out string password, out string authority)
      {
        authCookie = null;
        user = password = authority = null;
        return false;
     }
}

Then set your credentials like this:

IReportServerCredentials Creds = new CustomReportCredentials("Administrator", "password", "domain"); //to actual values
myReportViewer.ServerReport.ReportServerCredentials = Creds;


in .NET core as well in .NET 5.0 replace "reportViewer.ServerReport.ReportServerCredentials" with "reportViewer.ServerReport.ReportServerCredentials.NetworkCredentials = new System.Net.NetworkCredential(Username,Password,Domain);"

also you Should install "Microsoft.Reporting.WinForms" NuGet

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜