AASPXCOM

关于C# 的一切!!!!!

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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

 

posted on 2013-03-21 10:39  AASPXCOM  阅读(302)  评论(0)    收藏  举报