Domanda

Voglio essere in grado di visualizzare un database di SQL Server 2005 Reporting Services da un ASP.NET applicazione in una DMZ attraverso un controllo ReportViewer.Il SQLand SSRS server sono protetti da un firewall.

È stato utile?

Soluzione

`Ho avuto modo di cambiare il modo in cui un ASP.NET 2.0 applicazione denominata report dalle pagine.Inizialmente, ho utilizzato JavaScript per aprire una nuova finestra.

ViewCostReport.OnClientClick = "window.open('" + Report.GetProjectCostURL(_PromotionID) + "','ProjectCost','resizable=yes')";

Il problema che ho avuto è stata quella finestra.invito aperto a funzionare solo all'interno del client di rete e non su un nuovo server web, nella DMZ.Ho dovuto creare un nuovo report WebForm che incorporato un controllo ReportViewer per visualizzare il report.

L'altro problema che ho avuto è che il Server di Report avuto accesso con Autenticazione di windows, dal momento che è stato utilizzato da un'altra applicazione per i rapporti e che app usate ruoli per l'accesso ai report.Così sono andato a prendere il mio controllo ReportViewer per impersonare un utente di windows.Ho trovato la soluzione per essere questo:

Creare una nuova classe che implementa il sistema di Microsoft.La segnalazione.WebForms.IReportServerCredentials interfaccia per l'accesso al report.

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;
    }
}

Poi ho creato un evento per il pulsante per chiamare il report:

protected void btnReport_Click(object sender, EventArgs e)
{
    ReportParameter[] parm = new ReportParameter[1];
    parm[0] =new ReportParameter("PromotionID",_PromotionID);
    ReportViewer.ShowCredentialPrompts = false;
    ReportViewer.ServerReport.ReportServerCredentials = new ReportCredentials("Username", "Password", "Domain");
    ReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
    ReportViewer.ServerReport.ReportServerUrl = new System.Uri("http://ReportServer/ReportServer");
    ReportViewer.ServerReport.ReportPath = "/ReportFolder/ReportName";
    ReportViewer.ServerReport.SetParameters(parm);
    ReportViewer.ServerReport.Refresh();
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top