Progress
Language Reference


SETUSERID Function

Interfaces
OS
SpeedScript
All
All
Yes

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.

SYNTAX

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

userid

A constant, field name, variable name, or expression that results in a character value that represents the user’s user ID. If you use a constant, you must enclose it in quotation marks (" ").

password

A constant, field name, variable name, or expression that results in a character value that represents the user’s password. If you use a constant, you must enclose it in quotation marks.

logical-dbname

The logical name of the database where you want to check and set your user ID. The logical database name must be a character string enclosed in quotes, or a character expression. If you do not specify this argument, the Compiler inserts the name of the database that is connected when the procedure is compiled. If you omit this argument and more than one database is connected, it results in a Compiler error.

EXAMPLE

To use the login.p procedure that is provided with Progress, 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.
DEFINE VARIABLE password LIKE _Password.
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 */
  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 Progress with the QUIT statement.

NOTES

SEE ALSO

CONNECT Statement, USERID Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095