! ----- GRANT_OR_DENY_OTHER.FUN ----- ! ! ----- SUBROUTINE TO GRANT OR DENY ACCESS TO OTHER DATABASES ----- ! ! ---------- PASSED: ---------- ! ! ----- ACTION_INDEX = User-entered index into USER_ACTIONS() ! ----- DBMS_PREFIX = 3-char identifier prefix for the database ! ----- product ! ----- DBMS_PRODUCT = Description of database product ! ----- DEBUG_MODE = TRUE if Debug Mode was enabled ! ----- FOUR_GL = Description of 4GL language ! ----- FOUR_GL_PREFIX = 4-char identifier prefix for the 4GL ! ----- GRANT_DENY_OTHER_NODES = TRUE if Cluster-Wide Grant/Deny ! ----- NODE_LIST = List of nodes that user is on ! ----- OTHER_IDENTS() = List of other databases or 4GL ! ----- identifiers to grant or deny ! ----- OTHER_IDENTS_DB() = List of other template databases to ! ----- be used when granting database access ! ----- OTHER_IDENTS_CTR = Count of other databases or 4GL ! ----- identifiers to grant or deny ! ----- OTHER_IDENTS_TEMPLATE() = List of templates to use when ! ----- granting the other databases ! ----- USER_ACTIONS() = List of all possible user actions ! ! ----- Last Change 07/08/94 by Brian Lomasky ----- ! SUB GRANT_OR_DENY_OTHER(STRING NODE_LIST) %INCLUDE "NUSER.INC" DECLARE STRING A_NODE ! A NODE TO BE PROCESSED DECLARE STRING DB_AND_TEMPLATE ! DB/TEMPLATE TO USE FOR GRANT DECLARE STRING GRANT_DENY_DB ! DATABASE/4GL TO GRANT/DENY DECLARE STRING LOCAL_NODE_LIST ! COPY OF NODE_LIST DECLARE LONG OTHER_INDEX ! OTHER IDENTIFIER ARRAY INDEX DECLARE WORD TEMP ! TEMPORARY WORD VARIABLE DECLARE STRING THE_DB ! TEMPORARY DATABASE/4GL NUMBER DECLARE STRING THE_DESC ! DISPLAYED GRANT/DENY DESC EXTERNAL WORD FUNCTION GRANT_IDENTIFIER(STRING, WORD, & STRING) ! GRANT AN IDENTIFIER EXTERNAL WORD FUNCTION IF_HELD_IDENTIFIER( & STRING) ! TRUE IF IDENTIFIER IS HELD EXTERNAL WORD FUNCTION NUSER_OTHER(STRING, & STRING, STRING) ! PERFORM ALL NON-STD PROCESSING EXTERNAL WORD FUNCTION & REVOKE_IDENTIFIER ! REVOKE AN IDENTIFIER FROM USER EXTERNAL WORD FUNCTION REVOKE_NODE_IDENTIFIER(STRING, & WORD) ! REVOKE AN IDENTIFIER FROM NODE SELECT USER_ACTIONS(ACTION_INDEX) CASE "G" ! IF GRANTING ACCESS: THE_DESC = "Grant" CASE "X" ! IF DENYING ACCESS: THE_DESC = "Deny" END SELECT IF DEBUG_MODE THEN PRINT "GRANT_OR_DENY_OTHER DEBUG>" + & "GRANT_DENY_OTHER_NODES="; & GRANT_DENY_OTHER_NODES PRINT "GRANT_OR_DENY_OTHER DEBUG>NODE_LIST=" + NODE_LIST END IF PRINT !IF OTHER_IDENTS_CTR = 1% THEN ! PRINT "Processing 1 database..." !ELSE ! PRINT "Processing " + NUM1$(OTHER_IDENTS_CTR) + & ! " databases..." !END IF OTHER_INDEX = 0% WHILE OTHER_INDEX < OTHER_IDENTS_CTR OTHER_INDEX = OTHER_INDEX + 1% GRANT_DENY_DB = TRM$(OTHER_IDENTS(OTHER_INDEX)) DB_AND_TEMPLATE = OTHER_IDENTS_DB(OTHER_INDEX) & + OTHER_IDENTS_TEMPLATE(OTHER_INDEX) IF DEBUG_MODE THEN PRINT "DEBUG>" + THE_DESC + & " access to " + GRANT_DENY_DB END IF !PRINT "Processing database #" + & ! NUM1$(OTHER_INDEX) + "..." ! ----- SEE IF WE SHOULD ALSO GRANT/DENY THE ----- ! ----- IDENTIFIER ON OTHER NODES ----- IF GRANT_DENY_OTHER_NODES THEN ! ----- MOVE TO LOCAL VARIABLE ----- LOCAL_NODE_LIST = NODE_LIST PRINT "Processing node list of " + & LOCAL_NODE_LIST + "..." WHILE LOCAL_NODE_LIST <> "" TEMP = POS(LOCAL_NODE_LIST, ",", 1%) IF TEMP = 0% THEN LOCAL_NODE_LIST = "" ITERATE END IF A_NODE = LEFT(LOCAL_NODE_LIST, & TEMP - 1%) LOCAL_NODE_LIST = RIGHT( & LOCAL_NODE_LIST, TEMP + 1%) IF A_NODE = "" THEN LOCAL_NODE_LIST = "" ITERATE END IF ! ----- SEE IF DATABASE ACCESS ----- IF LEN(GRANT_DENY_DB) = 3% THEN PRINT THE_DESC + & "ing user" + & " access to" + & " the " + TRM$( & DBMS_PRODUCT) + & " " + & GRANT_DENY_DB + & " database" + & " on node " + & A_NODE + "..." ! ----- GRANT/DENY THIS ----- ! ----- USERNAME THE ----- ! ----- DATABASE ----- ! ----- IDENTIFIER ON THE ----- ! ----- SPECIFIED NODE ----- THE_IDENT = DBMS_PREFIX & + GRANT_DENY_DB ELSE ! ADDING A 4GL DATABASE ACCESS: ! ----- REMOVE THE ----- ! ----- LEADING "F" ----- THE_DB = RIGHT( & GRANT_DENY_DB, 2%) PRINT THE_DESC + & "ing user" + & " access to" + & " the " + & TRM$(FOUR_GL) + & " " + THE_DB + & " database" + & " on node " + & A_NODE + "..." ! ----- GRANT/DENY THIS ----- ! ----- USERNAME THE 4GL ----- ! ----- IDENTIFIER ON THE ----- ! ----- SPECIFIED NODE ----- THE_IDENT = & FOUR_GL_PREFIX + THE_DB END IF SELECT USER_ACTIONS(ACTION_INDEX) CASE "G" ! IF GRANTING ACCESS: ! ----- GRANT ON A ----- ! ----- SPECIFIC NODE ----- TEMP = GRANT_IDENTIFIER(& A_NODE, FALSE, "") CASE "X" ! IF DENYING ACCESS: ! ----- REVOKE FROM A ----- ! ----- SPECIFIC NODE ----- TEMP = REVOKE_NODE_IDENTIFIER(& A_NODE, FALSE) END SELECT NEXT ELSE ! ----- SEE IF DATABASE ACCESS ----- IF LEN(GRANT_DENY_DB) = 3% THEN PRINT THE_DESC + & "ing user access" + & " to the " + TRM$( & DBMS_PRODUCT) + " " + & GRANT_DENY_DB + " database..." ! ----- GRANT/DENY THIS USERNAME ----- ! ----- THE DATABASE IDENTIFIER ON ----- ! ----- THE LOCAL NODE ----- THE_IDENT = DBMS_PREFIX + GRANT_DENY_DB ELSE ! ADDING A 4GL DATABASE ACCESS: ! ----- REMOVE THE LEADING "F" ----- THE_DB = RIGHT(GRANT_DENY_DB, 2%) PRINT THE_DESC + "ing user" + & " access to the " + & TRM$(FOUR_GL) + " " + & THE_DB + " database..." ! ----- GRANT/DENY THIS USERNAME ----- ! ----- THE 4GL IDENTIFIER ----- THE_IDENT = FOUR_GL_PREFIX + THE_DB END IF SELECT USER_ACTIONS(ACTION_INDEX) CASE "G" ! IF GRANTING ACCESS: TEMP = GRANT_IDENTIFIER("", FALSE, "") CASE "X" ! IF DENYING ACCESS: TEMP = REVOKE_IDENTIFIER END SELECT END IF ! ----- SEE IF SECURITY DATABASE ACCESS ALSO NEEDS ----- ! ----- TO BE GRANTED OR DENIED ----- IF LEN(GRANT_DENY_DB) <> 3% THEN IF DEBUG_MODE THEN PRINT "DEBUG>GRANT_DENY_DB=" + & GRANT_DENY_DB END IF ITERATE END IF SELECT USER_ACTIONS(ACTION_INDEX) CASE "G" ! IF GRANTING ACCESS: ! ----- ADD USER TO THIS DATABASE (CALL ----- ! ----- CHANGE TO DELETE ANY POSSIBLE OLD ----- ! ----- USER DATA) ----- TEMP = NUSER_OTHER("CHANGE_DB_USER", & GRANT_DENY_DB, DB_AND_TEMPLATE) CASE "X" ! IF DENYING ACCESS: IF GRANT_DENY_OTHER_NODES THEN ! ----- TRY TO REMOVE THIS USER ----- ! ----- FROM THE ----- ! ----- SECURITY DATABASE (IGNORE ----- ! ----- ERROR IF USER DOES NOT ----- ! ----- ALREADY EXIST) ----- TEMP = NUSER_OTHER( & "DELETE_DB_USER", & GRANT_DENY_DB, "") ELSE ! ----- TRY TO REMOVE THIS USER ----- ! ----- FROM THE ----- ! ----- SECURITY DATABASE, UNLESS ----- ! ----- THIS USER HOLDS THE ----- ! ----- DATABASE IDENTIFIER ON ANY ----- ! ----- OTHER NODE ----- IF DEBUG_MODE THEN PRINT "DEBUG>Call If_Held" END IF IF NOT IF_HELD_IDENTIFIER("") THEN ! ----- THIS USER DOES NOT ----- ! ----- HOLD THIS ----- ! ----- IDENTIFIER ON ANY ----- ! ----- OTHER NODE ----- TEMP = NUSER_OTHER( & "DELETE_DB_USER", & GRANT_DENY_DB, "") END IF END IF END SELECT NEXT END SUB