如何在ASP.NET程序中使用报表查看器控件并传递用户凭据
2009-05-21 14:39
731 查看
第一步,需要创建一个自定义的Credentails类型
public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
{ // local variable for network credential.
private string _UserName;
private string _PassWord;
private string _DomainName;
public CustomReportCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
}
public WindowsIdentity ImpersonationUser
{
get
{
return null; // not use ImpersonationUser
}
}
public ICredentials NetworkCredentials
{
get
{ // use NetworkCredentials
return new NetworkCredential(_UserName,_PassWord,_DomainName);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{ // not use FormsCredentials unless you have implements a custom autentication.
authCookie = null;
user = password = authority = null;
return false;
} } 第二步,在代码中这样编写 IReportServerCredentials irsc = new CustomReportCredentials(userid,password, domain);
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
{ // local variable for network credential.
private string _UserName;
private string _PassWord;
private string _DomainName;
public CustomReportCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
}
public WindowsIdentity ImpersonationUser
{
get
{
return null; // not use ImpersonationUser
}
}
public ICredentials NetworkCredentials
{
get
{ // use NetworkCredentials
return new NetworkCredential(_UserName,_PassWord,_DomainName);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{ // not use FormsCredentials unless you have implements a custom autentication.
authCookie = null;
user = password = authority = null;
return false;
} } 第二步,在代码中这样编写 IReportServerCredentials irsc = new CustomReportCredentials(userid,password, domain);
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
相关文章推荐
- 如何在ASP.NET中制作Web用户自定义控件,并在aspx页面中使用它的方法和属性?
- ASP.NET用户控件如何使用
- ASP.NET用户控件如何使用
- ASP.NET - 如何:使用 ASP.NET PasswordRecovery 控件启用用户密码恢复
- [PHP/.NET]如何把PHP站点用户登录会话传递到ASP.NET站点
- Asp.Net WebForm 母版页+用户控件的使用
- 使用ASP.NET的C#语言写后台如何将数据返回给微信小程序的JS
- (转)ASP.NET 2.0:使用用户控件和定制的Web部件个人化你的门户网站(一)
- ASP.NET中用户控件的使用
- asp.net mvc中使用用户控件 的二种方式
- ASP.net 用户控件(使用缓存)
- 如何使用jQuery向asp.net Mvc传递复杂json数据-ModelBinder篇
- 如何使用Administrators组用户运行ASP程序
- 使用MVC框架中要注意的问题(五):如何在页面和用户控件之间传递数据
- ASP.NET 用户控件的使用
- 绝对酷,如何解决asp.net中javascript脚本的问题(使用服务器控件执行客户端脚本)
- ASP.NET 用户控件的使用介绍
- 使用MVC框架中要注意的问题(五):如何在页面和用户控件之间传递数据
- asp.net中调用用户控件中的函数并传递参数
- 如何在asp.net中使用FreeTextBox控件