1

我有一个使用表单身份验证的 Web 表单应用程序。我有一个安装了 InfoView .NET 并且可以正常工作的 Crystal Reports Server 2008 V1 服务器。我有一些企业帐户设置。编辑:我应该提到我的 Web Forms 应用程序与 Crystal Reports Server 位于不同的服务器上。

我需要知道如何在我的自定义 ASP .NET 页面 (C#) 上以编程方式登录 InfoView .NET,然后将用户转移到 InfoView,而无需他们输入登录信息。

像这样的东西会很好(C#):

string username = "blah";
string password = "asdf";

// create logon token for crystal reports server
// .. // this is the code I need
Response.Redirect(url);

我确实找到了这个问题,它让我走到了那里,但它没有告诉我如何将令牌传递给 InfoView .NET。一些较旧的文档还提到需要 cookie。我还发现了其他站点,它们展示了如何将它传递给 Java InfoView,但我需要 .NET 版本。

4

2 回答 2

3

将此帖子用作此解决方案的参考。

这个解决方案有两个部分。

  • 自定义 Web 应用程序中用于创建 CMS 会话的页面
    • 因为我的网络应用程序知道登录的用户。
  • 服务器上绕过 InfoView 登录的页面
    • 因为我的网络应用程序无法为 InfoView 设置会话变量和 Cookie。

以下是步骤:

  1. 在您的网络应用程序中设置传输页面。
  2. 将所需的 DLL 复制到服务器上。
  3. 在服务器上设置旁路页面。

转移页面

  1. 您必须安装 Crystal Reports Server SDK。它可以从 Crystal Reports Server CD 安装(它被称为客户端工具或类似的东西)。
  2. 添加对 CrystalDecisions.Enterprise.Framework 的项目引用。将其设置为复制本地 = True。
  3. 创建一个页面。为其添加一个按钮。将 OnClick 事件添加到按钮。
  4. 页面代码隐藏命名空间参考:

    using CrystalDecisions.Enterprise;
    
  5. OnClick 事件代码

    string username = "user";
    string password = "password";
    string server = "CMSNAME:6400";
    string auth_type = "secEnterprise";
    // logon
    SessionMgr session_mgr = new SessionMgr();
    EnterpriseSession session = session_mgr.Logon(username, password, server, auth_type);
    // get the serialized session
    string session_str = session.SerializedSession;
    // pass the session to our custom bypass page on the CRS
    string url = "http://reportserver.domain.com/InfoViewApp/transfer.aspx?session="
    url += HttpUtility.UrlEncode(session_str);
    Response.Redirect(url);
    

复制 DLL

  1. 构建包含 Transfer 页面的项目。
  2. 在项目文件夹的 bin/Debug 下找到文件:CrystalDecisions.Enterprise.Framework.dll 并将其复制到服务器中:C:\Program Files\Business Objects\BusinessObjects Enterprise 12.0\Web Content\InfoViewApp\InfoViewApp\bin . 对于 Windows 2008 R2,路径中的“Program Files”应改为“Program Files (x86)”。

绕过页面

  1. 在服务器上打开记事本并将以下内容粘贴到其中。

    <%@ Page Language="C#" %>
    <script runat="server">
    private const string SESSION_PARAM = "session";
    private const string SESSION_KEY = "INFOVIEW_SESSION";
    private const string COOKIE_KEY = "InfoViewdotnetses";
    private const string LOGON_URL = "logon.aspx";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Request.QueryString[SESSION_PARAM] != null)
            {
                string sessionStrRaw = Request.QueryString[SESSION_PARAM];
                string sessionStr = System.Web.HttpUtility.UrlDecode(sessionStrRaw);
                CrystalDecisions.Enterprise.SessionMgr sessionMgr = new CrystalDecisions.Enterprise.SessionMgr();
                CrystalDecisions.Enterprise.EnterpriseSession entSession = sessionMgr.GetSession(sessionStr);
                BusinessObjects.Enterprise.Infoview.Common.CrystalIdentity identity;
                identity = new BusinessObjects.Enterprise.Infoview.Common.CrystalIdentity(entSession, System.Web.HttpContext.Current);
                HttpContext.Current.Session.Add(SESSION_KEY, identity);
                //Create the InfoViewdotnetses cookie which holds the SerializedSession
                HttpCookie InfoViewdotnetses = new HttpCookie(COOKIE_KEY);
                InfoViewdotnetses.Value = System.Web.HttpUtility.UrlEncode(sessionStrRaw);
                InfoViewdotnetses.Path = @"/";
                Response.Cookies.Add(InfoViewdotnetses);
            }
            Response.Redirect(LOGON_URL);
        }
        catch (Exception ex) { Response.Write(ex.ToString()); }
    }
    </script>
    
  2. 将页面作为 transfer.aspx 保存到:C:\Program Files\Business Objects\BusinessObjects Enterprise 12.0\Web Content\InfoViewApp\InfoViewApp。(对于 Windows 2008 R2,请参见上面的注释。)

就是这样。这对我有用。

于 2010-01-14T23:58:01.793 回答
1

这将解决您的问题:

将代码复制到 aspx 的 page_load 以将经过身份验证的令牌传递给报告。

    protected void Page_Load(object sender, EventArgs e)
    {
        string username = "user";
        string password = "password";
        string server = "<boe server>";
        string auth_type = "<auth type>";
        // e.g. string auth_type = "Windows AD"

        string token; string tokenEncoded; 

        int reportid = <reportid>; 
        string report_params = "<param1>=<value1>&<param2>=<value2>";

        // logon
        SessionMgr session_mgr = new SessionMgr();
        EnterpriseSession session = session_mgr.Logon(username, password, server, auth_type);

        // create token from session manager
        token = session.LogonTokenMgr.CreateLogonTokenEx("", 120, 100);
        tokenEncoded = HttpUtility.UrlEncode(token);

        // pass the token to the custom bypass page on the CRS
        string url = string.Format("http://{0}/OpenDocument/opendoc/openDocument.aspx?sIDType=wid&iDocID={1}&lsS{2}&token={3}",
            server, reportid, param, tokenEncoded);

        Response.Redirect(url);
    }
于 2011-07-13T18:50:37.957 回答