共用方式為


ReportServerCredentials.SetFormsCredentials 方法

指定連接到報表伺服器時將使用表單驗證,並提供表單認證。

命名空間:  Microsoft.Reporting.WinForms
組件:  Microsoft.ReportViewer.WinForms (在 Microsoft.ReportViewer.WinForms.dll 中)

語法

'宣告
Public Sub SetFormsCredentials ( _
    authCookie As Cookie, _
    userName As String, _
    password As String, _
    authority As String _
)
public void SetFormsCredentials(
    Cookie authCookie,
    string userName,
    string password,
    string authority
)
public:
void SetFormsCredentials(
    Cookie^ authCookie, 
    String^ userName, 
    String^ password, 
    String^ authority
)
member SetFormsCredentials : 
        authCookie:Cookie * 
        userName:string * 
        password:string * 
        authority:string -> unit 
public function SetFormsCredentials(
    authCookie : Cookie, 
    userName : String, 
    password : String, 
    authority : String
)

參數

  • authCookie
    類型:Cookie
    報表伺服器所用的驗證 Cookie。
  • userName
    類型:String
    將用來連接到報表伺服器的使用者名稱。
  • password
    類型:String
    將用來連接到報表伺服器的密碼。
  • authority
    類型:String
    驗證使用者時所用的權限,如 Windows 網域名稱。

範例

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace ReportServerCredentialsSample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;

            reportViewer1.ServerReport.ReportPath = 
                @"/Adventureworks Sample Reports/Company Sales";

            reportViewer1.ServerReport.ReportServerCredentials.SetFormsCredentials(
                null, <UserName>, <Password>, <DomainName>);
       
            reportViewer1.RefreshReport();
        }
    }
}

請參閱

參考

ReportServerCredentials 類別

Microsoft.Reporting.WinForms 命名空間