Try OpenEdge Now
skip to main content
Programming Interfaces
Data Management : Application Security : Using ABL callbacks in authentication systems : Creating an ABL authentication callback procedure : ABL authentication callback procedure example
 
ABL authentication callback procedure example
The authentication_callback.p example shows how to set up an ABL authentication callback procedure implemented with the appropriate type-name reference (Progress.Security.*.)for the PAMStatus class and with basic error handling. Note that the /* Perform validation */ comment is a placeholder for the section where you would add your own validation code.
You can use authentication_callback.p as a template for your own authentication callback.
authentication_callback.p
/* so that errors are thrown back to the main block */
ROUTINE-LEVEL ON ERROR UNDO, THROW.

USING Progress.Security.*.

/* Internal Procedures */
/* Procedure: AuthenticateUser
* Description: Perform the user account authentication action using the
* information in the Client-Principal object:
* a) Establishes the presence of the user account
* b) Validates the password(s)
* c) Optionally load user account information into the
* Client-Principal object.
* Can also perform the user account restriction checking
* using the information contained in the Client-Principal object:
* a) account enabled
* b) account day/time restrictions
* c) Client workstation/tty access
* d) Requirement for a new password
* NOTE: The ABL runtime will seal the Client-Principal object
* after the callback procedure returns.
*
*/
PROCEDURE AuthenticateUser:

DEFINE INPUT  PARAMETER hCP              AS HANDLE NO-UNDO.
DEFINE INPUT  PARAMETER cSystemOptions   AS CHARACTER EXTENT NO-UNDO.
DEFINE OUTPUT PARAMETER iPAMStatus       AS INTEGER INITIAL ? NO-UNDO.
DEFINE OUTPUT PARAMETER cErrorMsg        AS CHARACTER NO-UNDO.

/* Local variables */

DEFINE VARIABLE iActionStatus AS INTEGER NO-UNDO.
DEFINE VARIABLE checkStop     AS LOGICAL NO-UNDO.

DO ON STOP UNDO, LEAVE
ON QUIT UNDO, LEAVE :

iActionStatus = ?.

checkStop = YES.

/* Perform validation */

checkStop = NO.

CATCH e AS Progress.Lang.Error:
/* handle errors - possibly log error or set cErrorMsg */
iActionStatus = PAMStatus:Custom.
cErrorMsg = "Failed to process callback:" + e:GetMessage(1).
END.
END.
IF checkStop THEN DO:
ASSIGN iActionStatus = PAMStatus:Custom
cErrorMsg = "STOP Condition found".
 END.
 IF iActionStatus == ? THEN
iPAMStatus = PAMStatus:Success.
 ELSE
iPAMStatus = iActionStatus.
 END.
END.

/* Procedure: AfterSetIdentity
* Description: This is a notification that the AVM has set the credentials
* for the session or an OpenEdge database connection.
*/
PROCEDURE AfterSetIdentity:

DEFINE INPUT PARAMETER hCP AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER ss AS CHARACTER EXTENT NO-UNDO.

END.