IReportServerCredentials 介面
可讓物件提供用來連接到報表伺服器的認證。
命名空間: Microsoft.Reporting.WinForms
組件: Microsoft.ReportViewer.WinForms (在 Microsoft.ReportViewer.WinForms.dll 中)
語法
'宣告
Public Interface IReportServerCredentials
'用途
Dim instance As IReportServerCredentials
public interface IReportServerCredentials
public interface class IReportServerCredentials
type IReportServerCredentials = interface end
public interface IReportServerCredentials
IReportServerCredentials 型別公開下列成員。
屬性
名稱 | 說明 | |
---|---|---|
![]() |
ImpersonationUser | 指定連接到報表伺服器時所要模擬的使用者。 |
![]() |
NetworkCredentials | 傳回報表伺服器驗證所用的網路認證。 |
上層
方法
名稱 | 說明 | |
---|---|---|
![]() |
GetFormsCredentials | 提供用來連接到報表伺服器的表單驗證。 |
上層
範例
下列範例顯示 IReportServerCredentials 的實作。
using System;
using System.Data;
using System.Windows.Forms;
using System.Security.Principal;
using Microsoft.Reporting.WinForms;
class MyCredentials : IReportServerCredentials
{
public WindowsIdentity ImpersonationUser
{
get
{
return null;
}
}
public bool GetBasicCredentials(out string user, out string
password, out string domain)
{
user = <UserName>;
password = <Password>;
domain = <DomainName>;
return true;
}
public bool GetFormsCredentials(System.Net.Cookie myCookie, out
string user, out string password, out string authority)
{
myCookie = user = password = authority = null;
return false;
}
}
public class Demo : Form
{
public Demo()
{
this.Text = "Report Control Demo";
this.ClientSize = new System.Drawing.Size(950, 600);
ReportViewer reportViewer = new ReportViewer();
// Set Processing Mode.
reportViewer.ProcessingMode = ProcessingMode.Remote;
// Set server info.
reportViewer.ServerReport.ReportServerUrl = new
Uri("http://<ServerName>/reportserver");
reportViewer.ServerReport.ReportPath = "/Report
Project1/Report1";
reportViewer.ServerReport.ReportServerCredentials = new
MyCredentials();
// Add the reportviewer to the form.
reportViewer.Dock = DockStyle.Fill;
this.Controls.Add(reportViewer);
// Process and render the report.
reportViewer.RefreshReport();
}
[STAThread]
public static int Main(string[] args)
{
Application.Run(new Demo());
return 0;
}
}