2009-08-10 42 views
0

我可以提供某處用於查看報告的憑證嗎?這是一個在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

回答

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; 
    } 
} 
相關問題