1

pdfレポートをinとして実行しようとしていasp.net c#ます。を除いて、すべてがうまく機能していsqlauth cookieます。を使用しiframeてダミー レポートをレンダリングsqlAuthCookieし、コード ビハインドでその Cookie (レポート サーバーによって設定) を使用すると、それが機能するため、構文やメソッドなどが正しいことがわかります。私がする必要があるのはsqlauth cookie、ReportExecution サービスの Cookie コンテナーに追加するか、資格情報を渡す他の方法です。を使用してForms Authenticationいます。レポートを実行するための呼び出しでashxハンドラーを使用しています。jquery ajaxこれが私のコードビハインドページです。

  public void ProcessRequest(HttpContext context)
    {
        // 8863443a-06d6-4aeb-8fa8-43be545da1a3
        var rs = new ReportExecutionService();
        rs.Credentials = CredentialCache.DefaultCredentials;
        //rs.Credentials = new NetworkCredential("zachariah.curtis", "password", "AGLO");
        rs.Url = ConfigurationManager.AppSettings["ReportExecutionURL"];

        NetworkCredential creds = rs.Credentials.GetCredential(context.Request.Url, context.User.Identity.AuthenticationType);
        rs.LogonUser(creds.UserName, creds.Password, null);

        var cookies = context.Request.Cookies.AllKeys.ToList();
        var cookies3 = rs.CookieContainer.GetCookies(new Uri(rs.Url)); 
        var sqlauth = context.Request.Cookies["sqlAuthCookie"];
        rs.CookieContainer = new CookieContainer();
        cookies.ForEach(delegate(String item)
        {
            rs.CookieContainer.Add(new Cookie(context.Request.Cookies[item].Name, context.Request.Cookies[item].Value, context.Request.Cookies[item].Path, context.Request.Cookies[item].Domain ?? ".usda.gov"));
            rs.CookieContainer.Add(new Cookie("sqlAuthCookie", "A78B8A2D714BF058DF7258927717A4D34FA9F8A0BA54FCCB006543DEBF755D2670636E172675107A9FCAF77F66A0E7E2EE4321464602C7E61138C224B8612B05E12DC1DFF878E8748CE267FF19839198", "/", "iasdev.dev.sc.egov.usda.gov"));
        });


        // Render arguments
        byte[] result = null;
        // Make sure you use your correct org database name of the following line
        string reportPath = "/ProTractsCMT/TestReport";
        var contractId = context.Request["ContractId"];
        string format = "PDF";
        string historyID = null;
        string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";

        // Prepare report parameter.

        ParameterValue[] parameters = new ParameterValue[1];
        parameters[0] = new ParameterValue();
        parameters[0].Name = "@CONTRACTID";
        parameters[0].Value = contractId;

        DataSourceCredentials[] credentials = null;
        string showHideToggle = null;
        string encoding;
        string mimeType;
        string extension;
        Warning[] warnings = null;
        ParameterValue[] reportHistoryParameters = null;
        string[] streamIDs = null;

        ExecutionInfo execInfo = new ExecutionInfo();
        ExecutionHeader execHeader = new ExecutionHeader();

        rs.ExecutionHeaderValue = execHeader;

        execInfo = rs.LoadReport(reportPath, historyID);

        //rs.SetExecutionParameters(parameters, "en-us");
        string SessionId = rs.ExecutionHeaderValue.ExecutionID;


        Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID);

        try
        {
            result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
            execInfo = rs.GetExecutionInfo();
            Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime);
        }

        catch (SoapException err)
        {
            Console.WriteLine(err.Detail.OuterXml);
        }
        context.Response.ContentType = "text/plain";
        // save rendered pdf to db
        if (new calculations().SaveReport(result))
        {
            context.Response.Write("true");

        }
        else
        {
            context.Response.Write("true");

        }
    }

がどこrs.CookieContainer.Add(new Cookie("sqlAuthCookie"にあるかを見ることができ、それが私がそれを機能させる方法です。助けてくださいお願いします!!! 皆さんありがとう!

4

1 に答える 1

0

設計では、現在ログオンしているユーザーの資格情報/認証データをSSRSに渡す必要がありますか?それで、そのユーザーはその特定の資格情報を使用してレポートを直接実行することを許可されますか?

一般的に、RS実行エンジンにアクセスして、事前定義されたユーザーを使用して、明らかにすでに試した方法で実行すると仮定します。

 //rs.Credentials = new NetworkCredential("zachariah.curtis", "password", "AGLO");

これらのクレデンシャルは、アプリの設定で構成できます。

于 2011-03-18T23:36:17.610 に答える