硬编码报告服务凭证,无需提示即可在asp.net网站上查看报告

时间:2009-08-10 09:13:20

标签: asp.net rdl

我可以提供用于查看某些报告的某个凭据吗?这是在asp.net网站上的reportViewer控件中查看的.rdl报告。

1 个答案:

答案 0 :(得分:0)

您需要将凭据编码到ReportViewer控件中。看看下面的课程:

   public class ReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
    {
        string _userName, _password, _domain;
        public ReportCredentials(string userName, string password, string domain)
        {
            _userName = userName;
            _password = password;
            _domain = domain;
        }



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


    public System.Net.ICredentials NetworkCredentials
    {
        get
        {
         return new System.Net.NetworkCredential(_userName, _password, _domain);
        }
    }


    public bool GetFormsCredentials(out System.Net.Cookie authCoki, out string userName, out string password, out string authority)
    {
        userName = _userName;
        password = _password;
        authority = _domain;
        authCoki = new System.Net.Cookie(".ASPXAUTH", ".ASPXAUTH", "/", "Domain");
        return true;
    }
}