Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Tools and Features
Microsoft Reports
Class Library

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
IReportServerCredentials Interface

Allows objects to provide credentials to use for connecting to a report server.

Namespace: Microsoft.Reporting.WinForms
Assembly: Microsoft.ReportViewer.WinForms (in microsoft.reportviewer.winforms.dll)

Visual Basic (Declaration)
Public Interface IReportServerCredentials
Visual Basic (Usage)
Dim instance As IReportServerCredentials
C#
public interface IReportServerCredentials
C++
public interface class IReportServerCredentials
J#
public interface IReportServerCredentials
JScript
public interface IReportServerCredentials

The following example shows an implementation of IReportServerCredentials.

C#
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;
    }
}
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker