ASP.NET Web ReportViewer コントロールを介して ReportingServices に接続しようとしています。
rvContract.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
rvContract.ServerReport.ReportServerCredentials = new ReportServerCredentials("myUsername", "myNetworkPassword", "DOMAIN");
rvContract.ServerReport.ReportServerUrl = new Uri(ReportConfiguration.ReportServerUrl);
string rptPath = ReportConfiguration.RootPath;
if (!rptPath.EndsWith("/"))
{
rptPath += "/";
}
rvContract.ServerReport.ReportPath = rptPath + "AdminReports/Contract";
List<ReportParameter> reportParams = new List<ReportParameter>();
if (MkoSession.AccountId.HasValue)
{
ReportParameter accountId = new ReportParameter("AccountId", MkoSession.AccountId.Value.ToString());
}
rvContract.ServerReport.SetParameters(reportParams);
rvContract.ShowParameterPrompts = false;
rvContract.ShowZoomControl = false;
rvContract.ServerReport.Refresh();
rvContract.DataBind();
資格情報の実装は次のようになります。
public class ReportServerCredentials : IReportServerCredentials
{
private string _userName;
private string _password;
private string _domain;
public ReportServerCredentials(string userName, string password, string domain)
{
_userName = userName;
_password = password;
_domain = domain;
}
public WindowsIdentity ImpersonationUser
{
get
{
// Use default identity.
return null;
}
}
public ICredentials NetworkCredentials
{
get
{
// Use default identity.
return new NetworkCredential(_userName, _password, _domain);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{
// Do not use forms credentials to authenticate.
authCookie = null;
user = null;
password = null;
authority = null;
return false;
}
}
テスト中に資格情報をハードコーディングするだけです。チェックインする前に、このためのドメイン アカウントを作成する必要があります。
ReportService2005.asmx と ReportExecution2005.asmx (これが私の ReportServerUrl になります) の両方をブラウザーから問題なくヒットできます。
SetParameters 呼び出しに到達すると、WebException が発生します。例外内の応答のヘッダーを見ると、次のようになります。
{RSNotAuthenticated: True RSAuthenticationHeader: .ASPXFORMSAUTH Content-Length: 206 Cache-Control: private Content-Type: text/html; charset=utf-8 日付: 2013 年 9 月 24 日火曜日 16:15:08 GMT 場所: /ReportServer/logon.aspx?ReturnUrl=%2freportserver%2fReportExecution2005.asmx サーバー: Microsoft-HTTPAPI/2.0 X-AspNet-Version: 2.0。 50727
}
これは、ログインしていないことを示しているように見えます。その場合、まったく同じ資格情報を使用して、ブラウザーから Web サービスを表示するにはどうすればよいでしょうか?
ところで、ReportServerCredentials 実装の各メソッドにブレークポイントを設定したところ、各ブレークポイントにヒットしました。それが何を示しているのかわかりませんが、NetworkCredentials インターフェースは私のネットワーク資格情報を問題なく返しました。