</table>
//访问报表凭证用户
MyReportViewerCredential rp = new MyReportViewerCredential(MyReportViewerCredential.UserName, MyReportViewerCredential.Password, MyReportViewerCredential.domain);
reportViewer.ServerReport.ReportServerCredentials = rp;
reportViewer.ProcessingMode = ProcessingMode.Remote;
reportViewer.ShowToolBar = false;
ServerReport serverReport = reportViewer.ServerReport;
serverReport.ReportServerUrl = new Uri(CommonProc.ReportServerUrl);
serverReport.ReportPath = "/投资批复费用报表";
//访问报表凭证用户
ReportParameter param = new ReportParameter();
param.Name = "StartDate";
string strStratDate = PlanDateStartTime.SelectedDate.Trim();
param.Values.Add(strStratDate);
ReportParameter param1 = new ReportParameter();
param1.Name = "EndDate";
string strEndDate = PlanDateEndTime.SelectedDate.Trim();
param1.Values.Add(strEndDate);
reportViewer.ServerReport.SetParameters(new ReportParameter[] { param });
reportViewer.ServerReport.SetParameters(new ReportParameter[] { param1 });
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.Web.SessionState;
using System.Web.Security;
using Microsoft.Reporting.WebForms;
using System.Security.Principal;
/// <summary>
///ReportCertificate 的摘要说明
/// </summary>
public class MyReportViewerCredential:IReportServerCredentials
{
//配置报表用户的用户名,密码和域
public static string UserName = System.Configuration.ConfigurationSettings.AppSettings["UserReportServerName"].ToString();
public static string Password = System.Configuration.ConfigurationSettings.AppSettings["UserReportServerPassword"].ToString();
public static string domain = System.Configuration.ConfigurationSettings.AppSettings["Domain"].ToString();
//私有变量
private string _username; //用户名
private string _password; //密码
private string _domain; //域
/// <summary>
/// 构造函数
/// </summary>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <param name="domain">域</param>
public MyReportViewerCredential(string username, string password, string domain)
{
_username = username;
_password = password;
_domain = domain;
}
/// <summary>
/// 实现IReportServerCredentials接口的成员属性(ImpersonateUser)
/// </summary>
public WindowsIdentity ImpersonationUser
{
get { return null; }
}
/// <summary>
/// 实现IReportServerCredentials接口的成员属性(NetworkCedentials)
/// </summary>
public System.Net.ICredentials NetworkCredentials
{
get { return new NetworkCredential(_username, _password, _domain); }
}
/// <summary>
/// 实现IReportServerCredentials接口的成员方法(GetFormCedentials)
/// </summary>
/// <param name="authCookie">Cookie类对象</param>
/// <param name="user">用户名</param>
/// <param name="password">密码</param>
/// <param name="authority">域</param>
/// <returns></returns>
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{
authCookie = null;
user = _username;
password = _password;
authority = _domain;
return false;
}
}
http://www.cnblogs.com/BlueWoods/archive/2009/04/27/1444311.html
http://blog.csdn.net/hebeijg/article/details/7328932
http://www.microsoft.com/zh-cn/download/details.aspx?id=35747
http://blog.csdn.net/hebeijg/article/details/7328932
http://www.dotblogs.com.tw/yangxinde/archive/2012/11/07/80655.aspx
http://www.360doc.com/userhome.aspx?userid=7664736&cid=6#