PreviousNextIndex

SETUSERID function

Returns a TRUE value and assigns the user ID to the user if the user ID and password supplied to the SETUSERID function are in the _User table. If the user ID is not in the _User table or the password is incorrect, SETUSERID returns a FALSE value and does not assign the user ID to the user.

Note: Using this function overrides the database user ID previously set by either the SET-CLIENT( ) method or the SET-DB-CLIENT function.
Syntax

SETUSERID ( userid , password [ , logical-dbname ] ) 

userid
password
logical-dbname
Example

To use the login.p procedure that is provided with ABL, you must define user IDs and passwords for those users who are authorized to access the database.

r-login1.p
/* Prompt user for userid and password and set the userid */ 
DEFINE VARIABLE id       LIKE _User._Userid NO-UNDO. 
DEFINE VARIABLE password LIKE _Password     NO-UNDO. 
DEFINE VARIABLE tries    AS INTEGER         NO-UNDO. 
IF USERID("DICTDB") <> "" OR NOT CAN-FIND(FIRST DICTDB._User) THEN RETURN. 
DO ON ENDKEY UNDO, RETURN:  /* return if they hit endkey */ 
  /* Reset id and password to blank in case of retry */ 
  ASSIGN 
    id       = "" 
    password = "". 
  UPDATE SPACE(2) id SKIP  password BLANK 
    WITH CENTERED ROW 8 SIDE-LABELS ATTR-SPACE 
    TITLE " Database " + LDBNAME("DICTDB") + " ".  
  IF NOT SETUSERID(id, password, "DICTDB") THEN DO: 
    MESSAGE "Sorry, userid/password is incorrect.". 
    IF tries > 1 THEN QUIT. /* Only allow 3 tries */ 
    tries = tries + 1. 
    UNDO, RETRY. 
  END. 
  HIDE ALL. 
  RETURN. 
END. 
QUIT. 

The login.p procedure uses the SETUSERID function to check the value of the user ID and password that a user enters. If the value of the function is FALSE, the procedure allows the user another try. The user has three tries to log in. The first time, the tries variable is 0; tries is 1 the second time, and 2 the third. The third time, tries is greater than 1 and the procedure exits from ABL with the QUIT statement.

Notes
See also

CONNECT statement, SET-CLIENT( ) method, SET-DB-CLIENT function, USERID function


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex