現在、SSRSの使用にいくつか問題があります。Windows認証を使用するASP.NETWebサイトがあります。これは正常に機能し、Webサイトの現在のユーザーが現在ログオンしているユーザーであることを私は知っています。
このサイトには、WebフォームのReportViewerがあります。クレデンシャルを設定しない場合、これは正常に機能します。ただし、SQL Serverのレポートの実行ログを見ると、ユーザー名はDOMAIN\MACHINEとしてリストされています。
ReportServerCredentialsプロパティを次のようなクラスに設定してみました。
[Serializable]
public class ReportCredentials : IReportServerCredentials
{
public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
{
authCookie = null;
userName = null;
password = null;
authority = null;
return false;
}
public WindowsIdentity ImpersonationUser
{
get {
return (WindowsIdentity)HttpContext.Current.User.Identity;
}
}
public ICredentials NetworkCredentials
{
get {
return null;
}
}
}
ただし、このコードを実行すると、Webサービスとレポートサービスから401が返されます。
どうしたの?それらは両方とも同じドメインにあります。現在のマシンではなく、現在のユーザーを使用したい。レポートサーバーでレポートを実行すると、Webサイトからではなく、正しいユーザー名でレポートが表示されます。