Consultor Eletrônico



Kbase P56478: How to prompt for username and password when launching Repor
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/27/2003
Status: Unverified

GOAL:

How to prompt for username and password when launching Report Builder

GOAL:

How to allow users to login to Report Builder using their own username and password

FIX:

It is not possible to get Report Builder itself to prompt for username and password but this can be done with 4GL.

In AppBuilder, create a window with 2 fill-ins (username = cUserID; password = cPassword) and a button.
In the trigger of the button, use the following code:

DO:
/* test connection to database with supplied credentials */
CONNECT sports2000 -H localhost -N tcp -S 9999 -U VALUE(cUserID:SCREEN-VALUE) -P VALUE(cPassword:SCREEN-VALUE) NO-ERROR.

IF ERROR-STATUS:ERROR THEN DO:
/* Login fails */
MESSAGE "Your credentials are not correct." SKIP "Please try again." VIEW-AS ALERT-BOX INFO BUTTONS OK.

/* Clear fields and return to username */
ASSIGN cUserID:SCREEN-VALUE = ""
cPassword:SCREEN-VALUE = "".
APPLY "entry" TO cUserID IN FRAME default-frame.
END.

ELSE DO:
/* Login succeeds */
DISCONNECT sports2000.

DEFINE VARIABLE cConnect AS CHARACTER NO-UNDO.

/* .PF contains -db -H -S -N parameters */
cConnect = "prorb32.exe -db sports2000 -H localhost -N tcp -S 9999 -U " + cUserID:SCREEN-VALUE + " -P " + cPassword:SCREEN-VALUE.

/* launch Report Builder */
OS-COMMAND NO-CONSOLE VALUE(cConnect).

/* Clear fields and return to username */
ASSIGN cUserID:SCREEN-VALUE = ""
cPassword:SCREEN-VALUE = "".
APPLY "entry" TO cUserID IN FRAME default-frame.
END.
END.