2009-09-17 33 views
7

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ですか?

+0

偽装ユーザーは、レポートサーバーへのアクセス権を持っていますか? – NYSystemsAnalyst

+0

あなたの開発マシン(localhost)の偽装ユーザーの下でIISを実行しようとしましたが、テストサーバーで起こっていることをより詳しくエミュレートしましたか?それは、レポートサーバーまたはレポートサーバーデータベースに対する偽装ユーザーのアクセス許可の問題のようなものです。偽装ユーザーがドメインアカウントであると仮定します。 –

+0

@NYSystemsAnalyst - はい、偽装ユーザーは、レポートサーバー上の適切なディレクトリにアクセスできます。 –

答えて

5

最後に問題を見つけました。当社のネットワーク管理者はダブルホッピングを無効にしているため、偽装がdomain\jmeyerとして正しく接続されている間に、アプリケーションはまだdomain\web01$というSRSボックスに接続しようとしていました。なぜこれはこのように設定されていますか?ダブルホッピングは大規模なセキュリティホールです。 (それとも私は言われました。何かのようなこの音はあなたがThe Daily WTFに読んでいましたでしょうか?)私たちのソリューションは、一般的なdomain\ssrs_report_servicesユーザーを作成し、以下のネットワーク資格情報を使用して、そのユーザーと接続することでした

public class CustomCredentials : 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 null; } 
    } 

    public ICredentials NetworkCredentials 
    { 
     get { return new NetworkCredential("ssrs_report_services", "password", "domain") ; } 
    }  
} 

上記は、あなたがインターネット上で見つけることができる古典的なサンプルソリューションです。

+0

実際、私はダブルホッピングがどのような設定でも「許可」されているとは思いません。なぜあなたの開発環境が動作していたのかはわかりませんが、多分構成が異なるでしょう。 –

+0

ローカルホスト(クライアントとして)→ローカルホスト(IISとして)→SRS –

+0

のように、ホップとしてカウントされないため、devsで動作します。サーバーベース。チェックアウト:http://serverfault.com/questions/16364/is-there-a-way-to-get-kerberos-credentials-to-delegate-twice-why-not –

2

「ダブルホップ」が許可されている - 特にそのレポート - Kerberos認証に急がせるを...(!、それが正常に動作しているよう)

+1

残念ながら、私たちの開発者は環境にかなり制約されており、インフラストラクチャには何の言葉もありません。しかし、私に何か新しいことを読んでくれてありがとう。 –

関連する問題