Torna al Thread

Imports System Imports System.Data Imports System.Configuration Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Imports Microsoft.Samples.ReportingServices Imports Microsoft.Reporting.WebForms Imports Microsoft.VisualBasic Imports System.Net Imports System.Security.Principal Partial Class fattbilla_rep Inherits System.Web.UI.Page Dim urlserver As String Dim port As String Dim reportingsrv As String Dim instance As IReportServerCredentials Dim lg As Logger Dim lgs As StringBuilder Protected Sub Page_Init(ByVal sender As Object, _ ByVal e As System.EventArgs) _ Handles Me.Init vw.ServerReport.ReportServerCredentials = _ New MyReportServerCredentials() End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click urlserver = "logisp" port = "8080" reportingsrv = "ReportServer" 'Creazione variabile dei parametri. Dim Params As List(Of Microsoft.Reporting.WebForms.ReportParameter) = _ New List(Of Microsoft.Reporting.WebForms.ReportParameter) 'Lista Parametri da passare al report Params.Add(New Microsoft.Reporting.WebForms.ReportParameter("mese", Me.DropDownList1.SelectedValue)) 'Passaggio dei parametri al Report. vw.ServerReport.ReportPath = "http://" & urlserver & ":" & port & "/" & reportingsrv & "/FatturazioneBilla_rep/Report2.rdl" vw.ServerReport.SetParameters(Params) End Sub End Class <Serializable()> _ Public NotInheritable Class MyReportServerCredentials Implements IReportServerCredentials Public ReadOnly Property ImpersonationUser() As WindowsIdentity _ Implements IReportServerCredentials.ImpersonationUser Get 'Use the default windows user. Credentials will be 'provided by the NetworkCredentials property. Return Nothing End Get End Property Public ReadOnly Property NetworkCredentials() As ICredentials _ Implements IReportServerCredentials.NetworkCredentials Get 'Read the user information from the web.config file. 'By reading the information on demand instead of storing 'it, the credentials will not be stored in session, 'reducing the vulnerable surface area to the web.config 'file, which can be secured with an ACL. 'User name Dim userName As String = _ ConfigurationManager.AppSettings("MyReportViewerUser") If (String.IsNullOrEmpty(userName)) Then Throw New Exception("Missing user name from web.config file") End If 'Password Dim password As String = _ ConfigurationManager.AppSettings("MyReportViewerPassword") If (String.IsNullOrEmpty(password)) Then Throw New Exception("Missing password from web.config file") End If lg.write("nwcred 3", lgs, "lognw.txt") 'Domain Dim domain As String = _ ConfigurationManager.AppSettings("MyReportViewerDomain") If (String.IsNullOrEmpty(domain)) Then Throw New Exception("Missing domain from web.config file") End If Return New NetworkCredential(userName, password, domain) End Get End Property Public Function GetFormsCredentials(ByRef authCookie As Cookie, _ ByRef userName As String, _ ByRef password As String, _ ByRef authority As String) _ As Boolean _ Implements IReportServerCredentials.GetFormsCredentials authCookie = Nothing userName = Nothing password = Nothing authority = Nothing 'Not using form credentials Return False End Function End Class
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5