cancel
Showing results for 
Search instead for 
Did you mean: 

SAP SSO with ASP.NET Web Application

Former Member
0 Kudos

Hi all,

I am trying to get my .NET Web application to authenticate against SAP using the .NET Toolkit and following the article: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/enabl... single sign-on for asp.net applications in enterprise portal 6.article.

I have added my web server into the same domain as the SAP Web Application Server and successfully managed to get the SAPSSO2 Cookie. However, I get this error when the toolkit is trying to instantiate a MySAPSso2Ticket, SAP.Web.Security.TicketException: MYSAP_INVALID. From the documentation, it states that Ticket syntactically invalid.

Any ideas what that means and any solutions?

Pls advise!!!

Regards

microlau

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Don't care about forum points. I'm glad I could help you.

By the way, thanks for the hint with the URL-Decode in the global.asax. I missed that one.

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

Can anyone help me....i need to know what this dstR3 refers to ..............pleaseeeeeeeee

Public Variables that read setting from web.config

Public strAppServerHost As String = ConfigurationSettings.AppSettings("dstR3.AppServerHost")

Public shtSystemNumber As Short = CType(ConfigurationSettings.AppSettings("dstR3.SystemNumber"), Short)

Public shtClient As Short = CType(ConfigurationSettings.AppSettings("dstR3.Client"), Short)

Former Member
0 Kudos

Hi All,

i need help in pulling the user information from SAP Portal to asp.net applciation....and i see that you were able to get the solution for it, can you please help me to proceed, it will be of great help......

you have asked to use the functiona and declare the funciton methods but im very new to htis concept and i need to know what appsettings to be used in the webcofig file............please let me know ...............thanks so much

Former Member
0 Kudos

I wrote a second application that reads out the ticket value, replaces all exclamation marks with %2B and stores it back into the cookie.

When I call this second application before I call the Ticket-Toolkit-Application then everything works fine.

Former Member
0 Kudos

Very, very, very thanks. I will try rigth now

Former Member
0 Kudos

WORKS YEAHHHH WORKS!!!!!!!

A very lot of thanks, you save my neck!!

Well I change my global asax for read the cookie like this:

Dim Cookie As String = HttpUtility.UrlDecode((Request.Cookies("MYSAPSSO2").Value).Replace("!", "%2B"))

An work very well

Thanks, thanks!!

Former Member
0 Kudos

How can I give you forum points.

Former Member
0 Kudos

Hi,

extend your ticket application so that it displays the value of the ticket toolkit and check if your ticket contains any exclamation marks. In my case this character causes the ticket check to fail.

Former Member
0 Kudos

Very thanks Marc.

But, I can delete this exclamation mark?

How do you fix this problem?

Very, very thanks.

darren_martin
Explorer
0 Kudos

Here is some sample code.....Not the best code but it may get you going down the right track.

Put this in a new module so that you can use it for any webform in your app.


    Function Is_SSO2Authenticated(ByVal objRequest As System.Web.HttpRequest, ByVal ObjUser As System.Security.Principal.IPrincipal, _
                              Optional ByRef strErrorMsg As String = "") As Boolean
        Dim blnReturnValue As Boolean = False
        Try
            If IsNothing(objRequest.Cookies("MYSAPSSO2")) = True Then
                strErrorMsg = "MySAPSSO2 Cookie not found"
            Else
                If ObjUser.Identity.IsAuthenticated = False Then
                    strErrorMsg = "User not authenticated."
                Else
                    If ObjUser.Identity.AuthenticationType <> "MYSAPSSO2" Then
                        strErrorMsg = "Authenticated by other Authentication Modulue."
                    Else
                        blnReturnValue = True
                    End If
                End If
            End If
        Catch ex As Exception
            blnReturnValue = False
            strErrorMsg = ex.Message
        End Try

        Return blnReturnValue

    End Function

Public Variables that read setting from web.config


Public strAppServerHost As String = ConfigurationSettings.AppSettings("dstR3.AppServerHost")
Public shtSystemNumber As Short = CType(ConfigurationSettings.AppSettings("dstR3.SystemNumber"), Short)
Public shtClient As Short = CType(ConfigurationSettings.AppSettings("dstR3.Client"), Short)

In your page load


        Try

            blnAuth = Is_SSO2Authenticated(Request, User, strMessage)

            If blnAuth = True Then

                Dim objIdent As SAP.Web.Security.MySAPSso2Identity
                objIdent = User.Identity

                With Me.dstR3
                    .MySAP_SSO2 = objIdent.TicketString
                    .AppServerHost = strAppServerHost
                    .SystemNumber = shtSystemNumber
                    .Client = shtClient
                End With

                With Me.YourProxy1
                    .Connection = Me.YourProxy1.Connection.GetConnection(Me.dstR3.ConnectionString)
                    .Connection.Open()
                End With

                If Me.YourProxy1.Connection.IsOpen = True Then
                    ' Do Something
                Else
                    ' Display No Connection Error 
                End If
            Else
                ' Display not authorized error
            End If
        Catch ex As Exception
            ' Display All other errors
        End Try

Former Member
0 Kudos

Hello.

¿Where I can download the SAPSECU.DLL.?

I tried down from Sap Download Area -> Sap Cripthography Software -> SAP Cryptographic Library Microsoft Win32 for x86/IA32, but in the car file have the "sapcrypto.dll".

¿It's good this file or do I going to find sapsecu.dll?

reiner_hille-doering
Active Contributor
0 Kudos

First check that your Verify.pse is the correct one.

Also make sure that you have all needed DLLs, espeacially SAPSECU.DLL.

If you are sure that this is Ok, you should try a step-by step procedure:

- Disable the Authentication Module in Web.config.

- In Page_Load of the page try to get the MYSAPSSO2-Cookie.

-UrlDecode it.

- Check that is looks ok (a valid Base64-encoded string).

-Create a new Ticket with the string and the correct PSE file.

Verify the ticket.

If all this works, also the Authentication Module should work (that does all the steps internally).

Former Member
0 Kudos

Does the .NET ticket toolkit described in the article works for workplace server version 2.11?

reiner_hille-doering
Active Contributor
0 Kudos

It should, because AFAIK it also creates MYSAPSSO2 tickets, but I haven't tested it.

Former Member
0 Kudos

Hi Reiner,

I have tried all the steps you mentioned but it seems that the SAP .NET Ticket Toolkit keeps returning ticket invalid error...Any advice?

Regards

microlau