0

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

4

1 回答 1

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;
    }
}
于 2009-08-10T11:09:51.593 回答