Imports System.Net Public Class CustomReportCredentials Implements Microsoft.Reporting.WebForms.IReportServerCredentials
' local variable for network credential Private strUserName As String Private strPassWord As String Private strDomainName As String Public Sub New(ByVal UserName As String, ByVal PassWord As String, ByVal DomainName As String) strUserName = UserName strPassWord = PassWord strDomainName = DomainName End Sub Public ReadOnly Property ImpersonationUser() As System.Security.Principal.WindowsIdentity Implements Microsoft.Reporting.WebForms.IReportServerCredentials.ImpersonationUser Get ' not use ImpersonationUser Return Nothing End Get End Property Public ReadOnly Property NetworkCredentials() As System.Net.ICredentials Implements Microsoft.Reporting.WebForms.IReportServerCredentials.NetworkCredentials Get ' use NetworkCredentials Return New NetworkCredential(strUserName, strPassWord, strDomainName) End Get End Property Public Function GetFormsCredentials(ByRef authCookie As System.Net.Cookie, ByRef userName As String, ByRef password As String, ByRef authority As String) As Boolean Implements Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials ' not use FormsCredentials unless you have implements a custom autentication. authCookie = Nothing password = authority = Nothing Return False End Function End Class
ServerReportUrl要指定SSRS的Report Server URL, 而不是Report Manager URL。因為這個URL的錯誤,讓我一直遇到404的錯誤.
ex: http://serverIP/ReportServer
Dim objParms As New System.Collections.ObjectModel.Collection(Of ReportParameter) objParms.Add(New ReportParameter("param1", "param1 value")) ReportViewer1.ServerReport.SetParameters(objParms)