Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

.Net SDK Login example for OpenDocument?

I'm looking for a quick example of logging into the CMS from a webpage using the .Net 4.0 SDK, and then simply opening a document using the URL call (I believe that's called OpenDocument by SAP).  Only requirement I really have is that it NOT take the user to the BI LaunchPad Login Screen.

I'm having a terrible time finding the correct DLL's to add into my project as references, I don't see a BusinessObjects.Enterprise or a CrystalReports.Enterprise, although there are a few DLL's out there that look promising, I can't find one that allows me to create a session or a login.

Anyone know how to do this?  If you have a little 10 line example, that would be ideal.  I could even go with a hack to create a session/login if I have to, but would rather do it correctly.



Former Member

Hello Matt,

I haven't had a chance to test it myself, but creating a logon token for OpenDocument in BI 4.0 should be the same as creating one for BOE 3.1. Kbase article 1201982 - How to create a logon token using the .NET SDK for use in OpenDocument has the code that should work. You'll have to be logged into the Service Marketplace (SMP) to view the KBA. I'll post the code here just in case.

There are some changes you'll have to account for. OpenDocument is now set up as a different application, so the base URL may be different.


'Add the following refernces to the project.

'Add the following Name space to the top of the code page.
      Imports CrystalDecisions.Enterprise

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'Enterprise Session Manager Variables
      Dim ceSessionMgr As New SessionMgr
      Dim ceSession As EnterpriseSession
      Dim ceToken As String

'Enterprise Credential Variables
      Dim apsUser As String = "<User ID>" 'Valid User ID
      Dim apsPassword As String = "<Password>" 'Valid User Password
      Dim cmsName As String = "<InfoviewServer>" 'Server running OpenDocument
      Dim apsAuthType As String = "secEnterprise" 'Authorization Type

'URL Reporting Report Variables
      Dim ceEnterpriseService As EnterpriseService
      Dim ceInfoStore As InfoStore
      Dim ceReportObjects As InfoObjects
      'Report is being hard coded in this example.
      'You can use other approaches to populate the reportid variable.
      'Your reportid values will be different.
      'Choose a valid report ID. The 'World Sales Report' reportID may not be 306 on your system
      Dim reportid As String = "306" ' - basic report, no parameters
      Dim sQuery As String

'Create Logon Token for use with Open Document method
      'logon to Enterprise
      ceSession = ceSessionMgr.Logon(apsUser, apsPassword, cmsName, apsAuthType)

'create the security token for this logon
      ceToken = ceSession.LogonTokenMgr.CreateLogonTokenEx("", 30, 100)

Catch err As Exception
      'error logging on
      lblError.Text = err.Message
      End Try

'Use Logon Token to build URL to view report with Open Document method
      'Logon with the token
      ceSession = ceSessionMgr.LogonWithToken(ceToken.ToString)
      ceEnterpriseService = ceSession.GetService("", "InfoStore")
      ceInfoStore = New InfoStore(ceEnterpriseService)

'Use query to confirm report is in crReportObjects collection
      sQuery = "Select * From CI_INFOOBJECTS Where SI_ID=" + reportid
      ceReportObjects = ceInfoStore.Query(sQuery)

'check for returned reports
      If ceReportObjects.Count > 0 Then

'Business Objects Enterprise 3.1 Open Document URL
      Response.Redirect(" http://<InfoviewServer>/OpenDocument/opendoc/opendocument.aspx?token=" + ceToken + "&iDocID=" + reportid)

      'no objects returned by query
      Response.Write("No report objects found by query <br>")
      Response.Write("Please click <a href='Default.aspx'>here</a> to return to the start page.<br>")
      End If

Catch err As Exception
      Response.Write("There was an error: <br>")
      Response.Write(err.Message.ToString + "<br>")
      End Try
End Sub

I hope this helps!


Dan Kelleher

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question