非域用户,reportview访问ssrs时提示:登录失败,(rsLogonFailed)

0
用reportview访问ssrs时提示:登录失败,(rsLogonFailed)
 
代码:
        private void Form1_Load(object sender, EventArgs e)
        {
            this.reportViewer1.ServerReport.ReportServerCredentials.SetFormsCredentials(null, "用户名", "密码", "");
            this.reportViewer1.RefreshReport();
        }
 
非域用户验证
 
已邀请:
0

- 取是能力,舍是境界 2016-10-20 回答

protected void Page_Load(object sender, EventArgs e)
{
ReportViewer1.ServerReport.ReportPath = reportPath;
ReportViewer1.ServerReport.ReportServerUrl = new Uri(report_url);
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerCredentials = new ReportSCredentials(rt_username, rt_password, rt_domain);
ReportViewer1.ServerReport.Refresh();
}
public class ReportSCredentials : IReportServerCredentials
{
private string _UserName;
private string _PassWord;
private string _DomainName;

public ReportSCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
}

public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get
{
return null;
}
}

public ICredentials NetworkCredentials
{
get
{
if (string.IsNullOrEmpty(_UserName) || string.IsNullOrEmpty(_PassWord))
{
return null;
}
else if (string.IsNullOrEmpty(_DomainName))
{
return new NetworkCredential(_UserName, _PassWord);
}
else
{
return new NetworkCredential(_UserName, _PassWord, _DomainName);
}
}
}

public bool GetFormsCredentials(out System.Net.Cookie authCookie, out string user, out string password, out string authority)
{
authCookie = null;
user = password = authority = null;
return false;
}

}

要回复问题请先登录注册