首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

reportview调用服务器报表的时候身份认证有关问题

2012-03-13 
reportview调用服务器报表的时候身份认证问题C# codepublic class CustomReportCredentials : Microsoft.R

reportview调用服务器报表的时候身份认证问题

C# code
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;        }    }


这个是微软的论坛上看到的认证的一个类
C# code
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;


调用的方法,但这个代码提示两个错误

错误1无法对属性或索引器“Microsoft.Reporting.WinForms.ServerReport.ReportServerCredentials”赋值 -- 它是只读的

错误2无法将类型“Microsoft.Reporting.WinForms.IReportServerCredentials”隐式转换为“Microsoft.Reporting.WinForms.ReportServerCredentials”。存在一个显式转换(是否缺少强制转换?)






[解决办法]
传说中的沙发

热点排行