Consultor Eletrônico



Kbase P38844: Dynamics: How to check if user has permission for a security
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/25/2003
Status: Unverified

GOAL:

Dynamics: How to check if user has permission for a security token?

FIX:

The following solution has been tested with Dynamics 2.0A02.
The tokenSecurityCheck API in the securityManager allows you to check if a user has a conflict with the permission defined with security allocation.


DEFINE VARIABLE hContainer AS HANDLE NO-UNDO.
DEFINE VARIABLE RestrictedToken AS CHARACTER NO-UNDO.
DEFINE VARIABLE SecuredObjectToCheck AS CHARACTER NO-UNDO.

SecuredObjectToCheck = "CustDepWin". /*'CustDepWin' is an example*/
RUN tokenSecurityCheck IN gshSecurityManager(
SecuredObjectToCheck,
"",
OUTPUT RestrictedToken).
IF LOOKUP("add",RestrictedToken) > 0
OR LOOKUP("copy",RestrictedToken) > 0
THEN DO:
MESSAGE "{&file-name}\" PROGRAM-NAME(1) SKIP
"Tokens for" SecuredObjectToCheck ":" RestrictedToken SKIP
"You have not permission for this operation"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
DYNAMIC-FUNCTION('cancelRow':U IN TARGET-PROCEDURE).
.... error handling .... cancel operation ....
END.

If the returned RestrictedToken is blank, then the user has no restriction. If it contains 'add' (for example), it then means that the 'add' token is defined for the SecuredObjectToCheck, and that the user has not permission for the add operation.