Skip to Content

Single Signon using C#

Hi, Have anyone been able to make and use a single sign-on connection using C#?

I successfully make the connection til the client and just after that I make the single-signon (As the UI-reference exsampel does). This single-signon is succesfully, but when I use the SAPBobs-company which I connected, in an event the company-object is corrupted (A Simple debugging fails for some reason)...

Anyone been able to use this feature with C#

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jun 04, 2004 at 08:24 AM

    This exsampel show the problems (see the comments in code on the event-handler method)

    public SAPbobsCOM.Company c = new SAPbobsCOM.Company();

    public SAPbouiCOM.Application app;

    public SAPbouiCOM.SboGuiApi gui = new SAPbouiCOM.SboGuiApiClass();

    private void Form1_Load(object sender, System.EventArgs e) {

    //Connect til SAP

    try {

    //Henter connection-string fra commandolinie og laver connect til SBO (gui)

    gui.Connect(Environment.GetCommandLineArgs()[1]);

    try {

    //Vælger SBO (Hvis flere kørende)

    app = gui.GetApplication(-1);

    }

    catch(Exception exp) {

    throw new Exception("Fejl under oprettelse af Application: "+exp.Message);

    }

    }

    catch {

    throw new Exception("SBO er ikke startet. Start det og prøv igen");

    }

    string cookie = c.GetContextCookie();

    string conStr = app.Company.GetConnectionContext(cookie);

    if(c.Connected) {

    c.Disconnect();

    }

    if(c.SetSboLoginContext(conStr) == 0) {

    c.Connect();

    }

    //Call methos that use company

    normal_method();

    //Registration Eventhandlers

    app.MenuEvent+=new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler(app_MenuEvent);

    }

    private void app_MenuEvent(ref SAPbouiCOM.MenuEvent pVal, out bool BubbleEvent) {

    BubbleEvent = false;

    //At this point c is corrupted (In a watch all properties is "error: cannot obtain value string")

    if(c.Connected) {

    MessageBox.Show("Test");

    }

    //Also if i try this alle properties in c2's watch is "<error: an exception of type: {System.InvalidCastException} occurred> SAPbobsCOM.BoSuppLangs"

    SAPbobsCOM.Company c2 = new SAPbobsCOM.Company();

    }

    private void normal_method() {

    if(c.Connected) {

    MessageBox.Show("Test2");

    }

    }

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.