Consultor Eletrônico



Kbase P55482: How to test if the current user has sufficient privileges to
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   21/11/2003
Status: Unverified

GOAL:

How to test if the current user has sufficient privileges to load a .df file before running the Progress supplied prodict\load_df.p procedure?

FIX:

To load a .df file, a user MUST have ·_Can-create· and ·_Can-write· permissions to the following four schema tables: files_File, _Field, _Index and _index-Field.

The following code checks if the current user is authorized to perform a .df load on the currently selected database or not:

/**********************************/
DEFINE VARIABLE lFailed AS LOGICAL NO-UNDO.

SESSION:SUPPRESS-WARNINGS = TRUE.
CREATE ALIAS DICTDB FOR DATABASE sports2000.
FOR EACH _File
WHERE _File._File-number >= -4 AND
_File._File-number <= -1:
IF CAN-DO(_File._Can-write,USERID("DICTDB")) AND
CAN-DO(_File._Can-create,USERID("DICTDB")) THEN NEXT.
lFailed = TRUE.
LEAVE.
END.

IF lFailed THEN
MESSAGE "Current user is not authorized to perform .df laod"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
ELSE
RUN prodict/load_df.p ("FileName.df") NO-ERROR.
DELETE ALIAS DICTDB.