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

请参阅

参考

Microsoft.Reporting.WinForms 命名空间