日期:2014-05-18 浏览次数:20760 次
public class CustomReportCredentials : Microsoft.Reporting.WinForms.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 WindowsIdentity ImpersonationUser { get { return null; // not use ImpersonationUser } } public ICredentials NetworkCredentials { get { // use NetworkCredentials return new NetworkCredential(_UserName, _PassWord, _DomainName); } } public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority) { // not use FormsCredentials unless you have implements a custom autentication. authCookie = null; user = password = authority = null; return false; } }
Microsoft.Reporting.WinForms.IReportServerCredentials ir=new CustomReportCredential("username","pwd","domain"); this.reportViewer1.ServerReport.ReportServerUrl = new Uri("http://192.168.0.1/reportserver"); this.reportViewer1.ServerReport.ReportPath = "/无标题"; this.reportViewer1.ServerReport.ReportServerCredentials = ir;