Consultor Eletrônico



Kbase P113962: 4GL/ABL: How to authenticate a user name and password after a blank  USERID connection to a database
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   12/3/2008
Status: Verified

GOAL:

4GL/ABL: How to authenticate a user name and password after a blank USERID connection to a database?

FACT(s) (Environment):

All Supported Operating Systems
Progress 8.x
Progress 9.x
OpenEdge 10.x

FIX:

/* The following procedure connects to the sports2000 database that has a list of valid users. The user initially connects to the database with a blank
user ID. The code then enters a loop that forces the user to provide a valid user ID and password for that database. */
DEFINE VARIABLE passwd AS CHARACTER FORMAT "x(16)" LABEL "Password".
DEFINE VARIABLE success AS LOGICAL.
DEFINE VARIABLE user-id AS CHARACTER FORMAT "x(32)" LABEL "User ID".
CONNECT sports2000.
success = FALSE.
DO WHILE NOT success:
MESSAGE "Enter a user ID and password for the database mywork.".
SET user-id passwd BLANK.
IF SETUSERID(user-id, passwd, "sports2000") THEN success = TRUE.
ELSE DO:
BELL.
MESSAGE "Invalid user ID and password; please try again.".
END.
END.
/* confirm that the USERID function returns the expected userid */
MESSAGE USERID('sports2000')
VIEW-AS ALERT-BOX INFO BUTTONS OK.