cancel
Showing results for 
Search instead for 
Did you mean: 

In Single sign-on - Error code:1000000004 Error msg:Unknown session

Former Member
0 Kudos

Hi,

While connecting to the company using single sign on i am getting the following error.

Error code : 1000000004

Error msg : Unknown session

any suggestion??

i am using following code.


OCT_SboGuiApi = New SAPbouiCOM.SboGuiApi
OCT_Company = New SAPbobsCOM.Company
strConnection = Environment.GetCommandLineArgs.GetValue(1)
OCT_SboGuiApi.Connect(strConnection)
GOD_Application = OCT_SboGuiApi.GetApplication()
strCookie = OCT_Company.GetContextCookie
strConnection = GOD_Application.Company.GetConnectionContext(strCookie)
lngGetCompanyString = OCT_Company.SetSboLoginContext(strConnection)
If OCT_Company.Connected = True Then
      OCT_Company.Disconnect()
End If
If Not lngGetCompanyString = 0 Then
      Exit Sub
End If
lngGetCompanyString = OCT_Company.Connect

Regards,

Mahendra

Edited by: Mahendrakumar on Sep 26, 2008 11:06 AM

Accepted Solutions (1)

Accepted Solutions (1)

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

In this case, you may need to restart the License Server, then it works fine.

Regards

-Yatsea

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi...

use this code...

Public Sub New()

MyBase.new()

StartApplication()

If Not SetConnectionContext() = 0 Then

SBO_Application.MessageBox("Failed setting a connection to DI API")

End ' Terminating the Add-On Application

End If

If Not ConnectToCompany() = 0 Then

SBO_Application.MessageBox("Failed connecting to the company's Data Base")

End ' Terminating the Add-On Application

End If

NI = 0

SBO_Application.MessageBox("PR Connected to : " & OCompany.CompanyName)

AddMenuItem()

End Sub

Private Sub StartApplication()

Dim SAPUI As SAPbouiCOM.SboGuiApi

Dim ConStr As String

SAPUI = New SAPbouiCOM.SboGuiApi

ConStr = Environment.GetCommandLineArgs.GetValue(1)

'ConStr = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"

SAPUI.Connect(ConStr)

'SAPUI.AddonIdentifier = "5645523035496D706C656D656E746174696F6E3A5830333832303233373832564E5607827D2ACACD0F468D337053739D921D8C"

SBO_Application = SAPUI.GetApplication

End Sub

Private Function ConnectToCompany() As Integer

Try

ConnectToCompany = OCompany.Connect

'ServerName = OCompany.Server

Catch ex As Exception

'SBO_Application.MessageBox(ex.Message)

End Try

End Function

Private Function SetConnectionContext() As Integer

Dim sCookie As String

Dim sConnectionContext As String

Dim lRetCode As Integer

OCompany = New SAPbobsCOM.Company

sCookie = OCompany.GetContextCookie

sConnectionContext = SBO_Application.Company.GetConnectionContext(sCookie)

If OCompany.Connected = True Then

OCompany.Disconnect()

End If

SetConnectionContext = OCompany.SetSboLoginContext(sConnectionContext)

End Function

regards...

Billa 2007

Former Member
0 Kudos

Try This.....


#Region "Single Sign On"
    Public WithEvents app As SAPbouiCOM.Application
    Public gui As SAPbouiCOM.SboGuiApi
    Public com As SAPbobsCOM.Company
    Private Sub SetApplication()
    Dim GuiSboGuiApi As SAPbouiCOM.SboGuiApi
    Dim StrConnectionString As String
    GuiSboGuiApi = New SAPbouiCOM.SboGuiApi
    Try
    StrConnectionString = Environment.GetCommandLineArgs.GetValue(1)
    GuiSboGuiApi.Connect(StrConnectionString)
    app = GuiSboGuiApi.GetApplication()
    Catch ex As IndexOutOfRangeException
    StrConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"
    GuiSboGuiApi.Connect(StrConnectionString)
    app = GuiSboGuiApi.GetApplication()
    Catch Ex As Exception
          app.MessageBox(Ex.Message)
    Finally
    End Try
    End Sub

    Private Function SetConnectionContext() As Integer
        Dim StrCookie As String
        Dim StrConnectionContext As String
        Try
            com = New SAPbobsCOM.Company
            com.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL
            StrCookie = com.GetContextCookie
            StrConnectionContext = app.Company.GetConnectionContext(StrCookie)
            If com.Connected = True Then
                com.Disconnect()
            End If
            SetConnectionContext = com.SetSboLoginContext(StrConnectionContext)
        Catch Ex As Exception
            app.MessageBox(Ex.Message)
        Finally
        End Try
    End Function

    Private Function ConnectToCompany() As Integer
        Try
            If com.Connected = True Then
                com.Disconnect()
            End If
            ConnectToCompany = com.Connect
        Catch Ex As Exception
            app.MessageBox(Ex.Message)
        Finally
        End Try
    End Function
#End Region

Former Member
0 Kudos

Thanks Sridhar,

actually my code is working but sometimes it gives this error.

i want to know the exact reason for the same.

regards,

Mahendra

Former Member
0 Kudos

When i tried to connect to the company database using the single sign-on i m getting the error message as "Unknown Session".

Please anyone give me the solution.