IReportServerConnection2-Schnittstelle
Stellt Verbindungsinformationen für den Berichtsserver bereit, wenn das Steuerelement für ReportViewer-Web Forms ohne Sitzungsstatus verwendet wird.
Namespace: Microsoft.Reporting.WebForms
Assembly: Microsoft.ReportViewer.WebForms (in Microsoft.ReportViewer.WebForms.dll)
Syntax
'Declaration
Public Interface IReportServerConnection2 _
Inherits IReportServerConnection, IReportServerCredentials
public interface IReportServerConnection2 : IReportServerConnection,
IReportServerCredentials
public interface class IReportServerConnection2 : IReportServerConnection,
IReportServerCredentials
type IReportServerConnection2 =
interface
interface IReportServerConnection
interface IReportServerCredentials
end
public interface IReportServerConnection2 extends IReportServerConnection, IReportServerCredentials
Der IReportServerConnection2-Typ macht die folgenden Member verfügbar.
Eigenschaften
Name | Beschreibung | |
---|---|---|
![]() |
Cookies | Ruft eine Auflistung benutzerdefinierter Cookies ab, um sie zum Berichtsserver zu senden. |
![]() |
Headers | Ruft eine Auflistung benutzerdefinierter Kopfzeilen ab, um sie zum Berichtsserver zu senden. |
![]() |
ImpersonationUser | Ruft die WindowsIdentity des Benutzers ab, dessen Identität angenommen werden soll, bzw. legt diese fest, wenn das ReportViewer-Steuerelement eine Verbindung mit einem Berichtsserver herstellt. (Von IReportServerCredentials geerbt.) |
![]() |
NetworkCredentials | Ruft die für die Authentifizierung am Berichtsserver verwendeten Netzwerkanmeldeinformationen ab bzw. legt diese fest. (Von IReportServerCredentials geerbt.) |
![]() |
ReportServerUrl | Gibt die URL des Berichtsservers zurück. (Von IReportServerConnection geerbt.) |
![]() |
Timeout | Ruft die Anzahl der Millisekunden ab, die auf Serverkommunikationen gewartet werden soll. (Von IReportServerConnection geerbt.) |
Zum Seitenanfang
Methoden
Name | Beschreibung | |
---|---|---|
![]() |
GetFormsCredentials | Stellt Informationen bereit, die zum Herstellen einer Verbindung mit einem Berichtsserver verwendet werden, der für die Formularauthentifizierung konfiguriert ist. (Von IReportServerCredentials geerbt.) |
Zum Seitenanfang
Hinweise
Wenn eine Implementierung der IReportServerConnection2-Schnittstelle in den Web.config-Einstellungen angegeben ist, werden die Werte der Eigenschaften ReportServerUrl, Timeout, Cookies und Headers in der ServerReport-Instanz nicht verwendet.Stattdessen werden die von der IReportServerConnection2-Implementierung bereitgestellten Werte verwendet.Zusätzlich zu diesen Eigenschaften werden die Anmeldeinformationen verwendet, die von der IReportServerConnection2-Implementierung bereitgestellt werden.
Weitere Informationen zum Angeben von Verbindungen mit dem ReportViewer-Steuerelement finden Sie unter Angeben von Verbindungen und Anmeldeinformationen für das ReportViewer-Webserversteuerelement.
Weitere Informationen zur Web.config-Einstellung ReportViewerServerConnection finden Sie unter Web.config-Einstellungen für ReportViewer.
Beispiele
Im folgenden Beispiel ist eine Implementierung der IReportServerConnection2-Schnittstelle dargestellt, mit der die Berichtsserver-URL und Anmeldeinformationen aus der Datei Web.config abgerufen werden können.
Vor der Anwendung des Beispiels müssen folgende fünf Schlüssel/Werte-Paare zur Web.config-Datei der Anwendung im appSettings-Block hinzugefügt werden: ReportViewerServerConnection, MyReportViewerUser, MyReportViewerPassword, MyReportViewerDomain und MyReportServerUrl. Dabei entsprechen die Werte dem Benutzername, Kennwort und der Domäne zur Verbindung zum Berichtsserver sowie der URL des BerichtsserversDer ReportViewerServerConnection-Wert muss auf den vollqualifizierten Assemblynamen für die Implementierung der IReportServerConnection2-Klasse festgelegt sein.
Weitere Informationen zur Web.config-Einstellung ReportViewerServerConnection finden Sie unter Web.config-Einstellungen für ReportViewer.
public sealed class MyReportServerConnection : IReportServerConnection2
{
public WindowsIdentity ImpersonationUser
{
get
{
// Use the default Windows user. Credentials will be
// provided by the NetworkCredentials property.
return null;
}
}
public ICredentials 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
string userName =
ConfigurationManager.AppSettings
["MyReportViewerUser"];
if (string.IsNullOrEmpty(userName))
throw new Exception(
"Missing user name from Web.config file");
// Password
string password =
ConfigurationManager.AppSettings
["MyReportViewerPassword"];
if (string.IsNullOrEmpty(password))
throw new Exception(
"Missing password from Web.config file");
// Domain
string domain =
ConfigurationManager.AppSettings
["MyReportViewerDomain"];
if (string.IsNullOrEmpty(domain))
throw new Exception(
"Missing domain from Web.config file");
return new NetworkCredential(userName, password, domain);
}
}
public bool GetFormsCredentials(out Cookie authCookie,
out string userName, out string password,
out string authority)
{
authCookie = null;
userName = null;
password = null;
authority = null;
// Not using form credentials
return false;
}
public Uri ReportServerUrl
{
get
{
string url =
ConfigurationManager.AppSettings[
"MyReportServerUrl"];
if (string.IsNullOrEmpty(url))
throw new Exception(
"Missing url from the Web.config file");
return new Uri(url);
}
}
public int Timeout
{
get
{
return 60000; // 60 seconds
}
}
public IEnumerable<Cookie> Cookies
{
get
{
// No custom cookies
return null;
}
}
public IEnumerable<string> Headers
{
get
{
// No custom headers
return null;
}
}
}
Public NotInheritable Class MyReportServerConnection
Implements IReportServerConnection2
Public ReadOnly Property ImpersonationUser() As WindowsIdentity _
Implements IReportServerConnection2.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 IReportServerConnection2.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
'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 IReportServerConnection2.GetFormsCredentials
authCookie = Nothing
userName = Nothing
password = Nothing
authority = Nothing
'Not using form credentials
Return False
End Function
Public ReadOnly Property ReportServerUrl() As Uri
Implements IReportServerConnection2.ReportServerUrl
Get
Dim url As String = ConfigurationManager.AppSettings("MyReportViewerUrl")
If (String.IsNullOrEmpty(url)) Then
Throw New Exception("Missing url from the web.config file")
End If
Return New Uri(url)
End Get
End Property
Public ReadOnly Property Timeout() As Integer Implements IReportServerConnection2.Timeout
Get
Return 60000 '60 seconds
End Get
End Property
Public ReadOnly Property Cookies() As IEnumerable(Of Cookie) Implements IReportServerConnection2.Cookies
Get
Return Nothing
End Get
End Property
Public ReadOnly Property Headers() As IEnumerable(Of String) Implements IReportServerConnection2.Headers
Get
Return Nothing
End Get
End Property
End Class
Siehe auch
Referenz
Microsoft.Reporting.WebForms-Namespace
Weitere Ressourcen
Web.config-Einstellungen für ReportViewer
Angeben von Verbindungen und Anmeldeinformationen für das ReportViewer-Webserversteuerelement