Skip to Content
Author's profile photo Former Member

Using Visual Studio 2012 and the BO 4.1 .NET SDK to Login using OpenDocument

Today, I needed to create a means to programmatically login to the BI Platform to and use OpenDocument syntax to allow Digital Signage screen access to some specific reports.  For the most part I was able to use the guidance documented in the following thread:

However, I wanted to share my specific solution with the community while the information is still fresh in my mind.

Step 1 : Download & Install the .NET SDK

First things first, get the runtime assemblies installed into your development environment (available from the SAP Service Marketplace).  Today I downloaded  used the 4.1 SP2 version.

Step 2: Create a new Project in VS2012 & Add References

Next, I created a new web project in VS:

New Project_2014-02-17_19-23-16.png

and then added the required references:

Reference Manager - DSOpenDocBridge_2014-02-17_19-25-39.png

From the screen shot, you can see that both the x64 and 32-bit assemblies are available.  For my project I included the 32-bit libraries and also configured my project to target x86 (vs. the Any CPU configuration).

Step 3: Get Coding

My goal was to create a web page that would use the SDK to get a single-use login token and accept a parameter off the URL (CUID) to a document id and then format a proper OpenDocument request to the server and open the corresponding report.

For reference I have included my full source code here:

using System;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using CrystalDecisions.Enterprise;
using System.Diagnostics;
namespace DSOpenDocBridge
    public partial class WebForm1 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            // Enterprise Session Manager Variables
            SessionMgr cdSessionManager = new SessionMgr();
            EnterpriseSession cdSession;
            String cdToken;
            String redirectURL;

            // CMS Credential Variables
            String cmsUser = ConfigurationManager.AppSettings["CMSUserName"].ToString();
            String cmsPassword = ConfigurationManager.AppSettings["CMSPassWord"].ToString();
            String cmsServer = ConfigurationManager.AppSettings["CMSServer"].ToString(); // <cms>:</port>
            // CMS Configuration Variables
            String cmsAuthType = ConfigurationManager.AppSettings["CMSAuthType"].ToString();
            // Choose a valid CUID for your report, in this case check the URL for a value passed with the request
            String documentCUID = "AT44N4.BDrZDgloAnjWWEvg";
            NameValueCollection qsCollection = HttpUtility.ParseQueryString(Request.Url.Query);
            if (qsCollection["DocCUID"] != null)
                documentCUID = qsCollection["DocCUID"];
            // Create Logon Token for use with Open Document method
                // logon to CMS & return the active session
                cdSession = cdSessionManager.Logon(cmsUser, cmsPassword, cmsServer, cmsAuthType);
                // create the security token for this logon
                // The createLogonToken method allows you to specify the machine that can use the token (which
                // can be empty to allow any user to use the token), the number of minutes the token is valid for, and
                // the number of logons that the token can be used for as parameters.
                cdToken = cdSession.LogonTokenMgr.CreateLogonTokenEx("", 5, 1);
                // now we use the token to build a URL to view the document with OpenDocument
                // Response.Redirect("http://<InfoviewServer>/OpenDocument/opendoc/opendocument.aspx?token=" + ceToken + "&iDocID=" + reportid)
                redirectURL = ConfigurationManager.AppSettings["OpenDocURL"].ToString() + "?&iDocID=" + HttpUtility.UrlEncode(documentCUID) + "&sIDType=CUID&token=" + HttpUtility.UrlEncode(cdToken);
                Response.Redirect(redirectURL, false);
            catch (Exception err)
                string errorMessage = "Error in: " + Request.Url.ToString() +
                        "\nError Message:" + err.Message.ToString();
                EventLog.WriteEntry("DSOpenDOcBridge", errorMessage, EventLogEntryType.Error);

and my (edited for sharing) web.config:

<?xml version="1.0"?>
  For more information on how to configure your ASP.NET application, please visit
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
      <customErrors mode="Off"/>
      <add key="CMSUserName" value="<username>"/>
      <add key="CMSPassWord" value="<password>"/>
      <add key="CMSServer" value="<servername>:<port>"/>
      <add key="CMSAuthType" value="secEnterprise"/>
      <add key="OpenDocURL" value="http://<servername>/BOE/OpenDocument/opendoc/openDocument.jsp" />

In the event of an error a message is written to the event log (requires appropriate permission).  Hopefully these notes will come in handy for someone else in the future.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.