cancel
Showing results for 
Search instead for 
Did you mean: 

Get SAP Logon Ticket in C# from web application on IIS running on different server than NetWeaver

Former Member
0 Kudos

Our company uses SSO to netweaver. I have a .net c# web application that is running on a different IIS server than netweaver that has to somehow programmatically get a SAP Logon Ticket string. I've downloaded the SAP .NET Conector 3.0 (2 DLLs) off of github, but don't see any methods to get a Logon Ticket.

Please let me know how I can accomplish this. Thanks!

Matt_Fraser
Active Contributor
0 Kudos

Hi Melanie,

I have adjusted the tags on this question to better reflect the topic, and hopefully draw in more relevant responses. Specifically, I moved it from "SAP NetWeaver" to "SAP Single Sign-On," and added "portal development kit for Microsoft .NET."

Cheers,
Matt

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Got it!

var request = (HttpWebRequest)WebRequest.Create(urlToPortal);

request.CookieContainer = newCookieContainer();

request.MaximumAutomaticRedirections = 4;

request.MaximumResponseHeadersLength = 4;

request.Credentials = CredentialCache.DefaultCredentials;

HttpWebResponse response = (HttpWebResponse) request.GetResponse();

model.RequestedEvent = response.StatusCode.ToString();

foreach (Cookie cook in response.Cookies)

{

if (cook.Name == "MYSAPSSO2")

{

model.SAPLoginTicket = cook.Value;

}

}

former_member723840
Discoverer
0 Kudos

I tried this, but I'm getting a 500 internal server error as response. But when I go to the URL directly, I was able to login using web.

Former Member
0 Kudos

Thanks Matt! I've gotten the login ticket from the browser cookie using C# and a HttpRedirect, but had to hard code user id and password. I need to be able to do this without providing a user id and password. Can anyone show me some code on how to accomplish this?