|
pfc_logon
|
|
Full name
|
n_cst_appmanager.pfc_logon
|
Access
|
public
|
Extend of
|
|
Return value
|
|
Prototype
|
event pfc_logon()
|
Name
|
Datatype
|
s_dbpassword
|
string
|
s_dbuserid
|
string
|
event pfc_logon;//////////////////////////////////////////////////////////////////////////////
//
// Event: pfc_logon
//
// Arguments:
// as_userid User ID attempting to logon.
// as_password Password of user attempting to logon.
//
// Returns: integer
// 1 = successful logon
// -1 = failure
//
// Description:
// Perform logon processing based on User ID and password given.
// If the Visual Guard security is activate, the application use the Visual Guard authentication
// else the application use the database authentication.
//
// Note:
// Visual Guard loads the database parameters from the section [VG DATABASE].
// In this section the password is encrypted.
//
// Subject: VISUAL_GUARD
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 1.0.00 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © Novalys
//////////////////////////////////////////////////////////////////////////////
string s_dbuserid, s_dbpassword
IF IsValid (inv_vgsecurity) THEN
// Use Visual Guard authentication
IF not SQLCA.of_IsConnected () THEN
// Load parameters from the INI-File
IF SQLCA.of_init (of_GetAppIniFile (), "VG Database") = -1 then
of_MessageBox ("pfc_systemerror", iapp_object.appname, &
"File " + of_GetAppIniFile () + " not found", exclamation!, OK!, 1)
Halt Close
End if
// Decrypt the password stored in the INI-File
inv_vgsecurity.of_gettransid (SQLCA, s_dbuserid, s_dbpassword)
inv_vgsecurity.of_settransid (SQLCA, s_dbuserid, inv_vgsecurity.of_decrypt (s_dbpassword))
// Connect the application to the database
IF SQLCA.of_connect () < 0 THEN
of_MessageBox ("pfc_systemerror", iapp_object.appname, &
"Unable to connect to the demo database.~r~n" + SQLCA.of_getsqlstate (), exclamation!, OK!, 1)
HALT Close
END IF
inv_vgsecurity.of_settransobject (SQLCA)
END IF
// Authenticates the user and loads security informations
Return inv_vgsecurity.of_verifyuser (as_userid, as_password)
ELSE
// Use the database authentication
IF SQLCA.of_init (of_GetAppIniFile (), "Database") = -1 then
of_MessageBox ("pfc_systemerror", iapp_object.appname, &
"File " + of_GetAppIniFile () + " not found", exclamation!, OK!, 1)
Halt Close
End if
IF SQLCA.DBHandle () > 0 THEN
DISCONNECT USING SQLCA;
END IF
SQLCA.dbparm = Left (SQLCA.dbparm, len(SQLCA.dbparm) -1) + "UID = " + as_userid + ";" + "PWD = " + as_password + "'"
IF SQLCA.of_connect () < 0 THEN
of_MessageBox ("vg_logondenied", iapp_object.appname, &
"Logon failed.", exclamation!, OK!, 1)
Return -7
END IF
END IF
Return 1
end event