AfterLogon Event Handler for an Application 

When a user logs into the business application, you want to check for authorization rights before giving access to the business application.

In the Application Modeler, write an AfterLogon event handler for the required application. For information on how to write an event handler, see Writing Scripts for an Interaction Component.

The code in the event handler can be:

AfterLogon (uname as string, pword as string, lang as string, success as Boolean)

On Error Resume Next

'>>> Login check begins

Dim EncryptedPassword As String

Dim CryptionObject As Object

Dim objBologin As Object

 

success = False

EncryptedPassword = ""

 

Set objBologin = gFactory.NewBusinessObject("LOGIN", uname)

Set CryptionObject = CreateObject("MSACRYPTING.Crypt")

if CryptionObject is nothing then exit sub

If pword <> "" Then

EncryptedPassword = CryptionObject.EncryptStringStandard(pword)

End If

 

If Not objBologin Is Nothing Then

If objBologin.Passwd <> EncryptedPassword Then

success = False

Else

success = True

End If

Else

success = False

End If

If success = False Then Exit Sub

'>>> Login check end

 

On error resume next

If Not gApplication.core Is Nothing Then

gApplication.core.BOL.UserDataDictionary.PutData "BwbUser", uname

gApplication.core.BOL.UserDataDictionary.PutData "BwbPWord", pword

gApplication.core.BOL.UserDataDictionary.PutData "BwbLang", lang

 

OpenKey CurrentUser, "Software\backweb\backweb\settings\OverrideLocale", True

WriteValue "language", GetUserLanguage(lang)

CloseKey

 

'added CHHI 19991015: language for SCE

OpenKey LocalMachine, "SOFTWARE\SAP\MSA\SCE\Database"

WriteValue "KBLanguage", lang

CloseKey

End If