SQL2005レポートサーバーにレポートを保存しましたが、このレポートのレンダリングされたPDFを返信します。 * .rdlファイルがローカルの.rdlcファイル(and I've blogged about it)で作業しているときにこれを認識しましたが、* .rdlがレポートサーバーに存在するときは見つかりませんでした。私は SSRSレポートビューア+ ASP.NET資格情報401例外
reportViewer.ServerReport.SetParameters(reportDefinition.ReportParameters);
はここでレポートをレンダリングするために使用される方法です...ラインで
401許可されていないエラーを取得しています。
public byte[] Render(IReportDefinition reportDefinition)
{
var reportViewer = new ReportViewer();
byte[] renderedReport;
try
{
var credentials = new WindowsImpersonationCredentials();
reportViewer.ServerReport.ReportServerUrl = new Uri("http://myssrsbox", UrlKind.Absolute);
reportViewer.ServerReport.ReportServerCredentials = credentials;
reportViewer.ServerReport.ReportPath = reportDefinition.Path;
// Exception is thrown on the following line...
reportViewer.ServerReport.SetParameters(reportDefinition.ReportParameters);
string mimeType;
string encoding;
string filenameExtension;
string[] streams;
Warning[] warnings;
renderedReport = reportViewer.ServerReport.Render(reportDefinition.OutputType, reportDefinition.DeviceInfo, out mimeType, out encoding, out filenameExtension, out streams, out warnings);
}
catch (Exception ex)
{
// log the error...
throw;
}
finally
{
reportViewer.Dispose();
}
return renderedReport;
}
もう1つの欠点は、WindowsImpersonationCredentialsクラスです。あなたが知る必要があるかもしれません
public class WindowsImpersonationCredentials : IReportServerCredentials
{
public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
{
authCookie = null;
userName = password = authority = null;
return false;
}
public WindowsIdentity ImpersonationUser
{
get { return WindowsIdentity.GetCurrent(); }
}
public ICredentials NetworkCredentials
{
get { return null; }
}
public override string ToString()
{
return String.Format("WindowsIdentity: {0} ({1})", this.ImpersonationUser.Name, this.ImpersonationUser.User.Value);
}
}
他のもの...
- これは、イントラネット上で実行されている、と偽装がオンになっています。
- ロギングは、偽装ユーザーが正しく設定されていることを示します。 Visual Studioの(
http://localhost:devport
)で実行しているとき - このはに動作し、そして私の開発ボックス(
http://localhost/myApplication
)上で動作しているときには、に動作します。テストサーバーまたは運用サーバーで実行している場合、はで動作しません。 - web.configのsystem.net.defaultProxy設定の有無にかかわらずソリューションを試しました。どちらもうまくいかなかった。
私は間違っていますか?サーバー設定ですか?それはコードですか?それはweb.configですか?
偽装ユーザーは、レポートサーバーへのアクセス権を持っていますか? – NYSystemsAnalyst
あなたの開発マシン(localhost)の偽装ユーザーの下でIISを実行しようとしましたが、テストサーバーで起こっていることをより詳しくエミュレートしましたか?それは、レポートサーバーまたはレポートサーバーデータベースに対する偽装ユーザーのアクセス許可の問題のようなものです。偽装ユーザーがドメインアカウントであると仮定します。 –
@NYSystemsAnalyst - はい、偽装ユーザーは、レポートサーバー上の適切なディレクトリにアクセスできます。 –