cancel
Showing results for 
Search instead for 
Did you mean: 

SSO logon ticket sample code for .NET?

Former Member
0 Kudos

Hi there,

I'm usually a BSP / Java developer for the SAP Portal but am currently having to so a .NET iView....

My question is: can someone give me some sample code that shows how to use logon tickets to get SSO working from the .NET portal application to R/3? I've searched the forums and have seen a few things like:

static void Main(string[] args)

{

string connStr = "<a full Connection string with username and password>";

string ticket = SAP.Connector.SAPConnection.GetSAPSSOTicket(connStr, 2);

Destination dest = new Destination();

dest.MySAP_SSO2 = ticket;

dest.AppServerHost = "<host>";

dest.SystemNumber = 50;

dest.Client = 800;

string c = dest.ConnectionString;

SAPConnection conn2 = new SAPConnection(dest);

conn2.Open();

}

BUT my problem comes into the FIRST line of code where it wants a username + password? In Java one of the ways to do SSO would be to simple pass through the request object...something like the following:

poolEntry = clientService.getJCOClientPoolEntry("MYSAPSERVER", <b>request</b>);

sapConnection = poolEntry.getJCOClient();

Surely there must be a VERY similar way in .NET? Or do I need to use cookies...perhaps something like the following?

Dim cookie As System.Web.HttpCookie

Dim dest As New SAP.Connector.Destination

dest.AppServerHost = "MYSAPSERVER"

dest.Client = 500

....

cookie = Request.Cookies.Get("MYSAPSSO2")

....

<b>dest.MySAP_SSO2 = cookie.Value</b>

dest.SystemNumber = 0

....

Dim cn As New SAP.Connector.SAPConnection(dest)

proxyInstance.Connection = cn

Thanks for the help!

BTW: I really don't want to use the "SAPLoginProvider" class.....

Regards

Lynton

Accepted Solutions (1)

Accepted Solutions (1)

reiner_hille-doering
Active Contributor
0 Kudos

Sure, this absolutely possible. The code sample that you quoted was for the case that you don't get the cookie from a portal. The only mussing this in an UrlDecode. Here is the corresponding code snipped from the detailed document https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/ep/d-f/enabling single sign-on for asp.net applications in enterprise portal 6.article

SAP.Connector.Destination dest = new SAP.Connector.Destination();

// set other properties here

dest.MySAP_SSO2 = HttpUtility.UrlDecode(this.Request.Cookies["MYSAPSSO2"].Value);

BTW: The SAPLoginProvider also contains this code-snipped, but additionally it supported form-based login.

Former Member
0 Kudos

Hi there,

Thanks a million for the help...it works!

Regard

Lynton

Former Member

Hi,

I'm using .Net connector 3.0 for SSO ticket and I'm unable to find "SAP.Connector"

could you please let me know how you been suceesful with SSO, if possible could you please send me the example?

Thanks a lot

Swamy

Former Member

Hi Lynton,

How are you. Hope your doing good. I have a similar kind of issue. I have developed a windows application using c sharp and had implemeted Single Sign on using Kerberos authentication using SNC and it works fine. But now i need to implement SSO with a SAP Portal using SAP logon tickets.Do you know how i can achieve this. If so could you please help me out.

Regards,

YD

Answers (0)