硬编码报告服务凭据可在无提示的情况下查看asp.net网站上的报告

问题描述:

我可以提供某处用于查看报告的凭证吗?这是一个在asp.net网站的reportViewer控件中查看的.rdl报告。硬编码报告服务凭据可在无提示的情况下查看asp.net网站上的报告

+0

你的意思是aspx页面主机reportViewer?为什么不把凭据放在同一页面上? – Dewfy 2009-08-10 09:25:16

+0

报告打开时询问用户标识和密码? – 2009-08-10 09:26:26

+0

如果您不提供凭据,则无法打开该网站 – agnieszka 2009-08-10 09:32:35

您需要将凭据编码到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; 
    } 
}