指定连接到报表服务器时要使用的窗体身份验证,并提供窗体凭据。
命名空间: 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 _
)
用法
Dim instance As ReportServerCredentials
Dim authCookie As Cookie
Dim userName As String
Dim password As String
Dim authority As String
instance.SetFormsCredentials(authCookie, _
userName, password, authority)
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
类型:System.Net.Cookie
报表服务器使用的身份验证 Cookie。
- userName
类型:System.String
将用于连接到报表服务器的用户名。
- password
类型:System.String
将用于连接到报表服务器的密码。
- authority
类型:System.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();
}
}
}