reportViewer 在winform 或者wpf 下获取用于报表服务器的凭据 代码书写,很多人都会用到
public class ReportCredentials : IReportServerCredentials { private string _serverUrl, _userName, _password; public string ServerUrl { get { return _serverUrl; } set { _serverUrl = value; } } public ReportCredentials() { var pars = ServiceLocator.Current.GetInstance<List<Parameter>>(Consts.Static_All_Parameter); var url = pars.Find(dd => dd.Code == Consts.Par_Global_ReportServerUrl); if (url != null) { _serverUrl = url.CurrentValue; } var name = pars.Find(dd => dd.Code == Consts.Par_Global_ReportServerUserName); if (name != null) { _userName = name.CurrentValue; } var password = pars.Find(dd => dd.Code == Consts.Par_Global_ReportServerPassword); if (name != null) { _password = password.CurrentValue; } } public WindowsIdentity ImpersonationUser { get { return null; } } public ICredentials NetworkCredentials { get { return new NetworkCredential(_userName,_password); } } public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority) { authCookie = null; userName = null; password = null; authority = null; return true; } }
以上内容来自http://www.aaspx.com/thread-117-1-1.html
浙公网安备 33010602011771号