! ----- FIND_IDENTIFIER.FUN ----- ! ! ----- SUBROUTINE TO LOOK UP AND STORE ALL UNIQUE IDENTIFIERS ----- ! ----- ASSOCIATED WITH A SPECIFIC USERNAME IN A SPECIFIC ----- ! ----- RIGHTLIST ----- ! ! ---------- PASSED: ---------- ! ----- HELD_IDENTS_CTR = Count of held identifiers that were ! ----- found before this subroutine was ! ----- called ! ----- RIGHTSLIST_FILE_INDEX = Rightslist file to search ! ----- USER_NAME = Username to lookup in the rightslist ! ---------- RETURNED: ---------- ! ----- DIV = Extracted 3-char Division Code (OTH if none; Blank ! ----- if error) ! ----- DIVISION_ACCESS = Extracted Divisional Access letter ! ----- (U if none; Blank if error) ! ----- HELD_IDENTS() = List of held identifier values ! ----- HELD_IDENTS_CTR = New count of held identifiers ! ----- HELD_IDENTS_STR() = List of held identifier strings ! ! ----- Last Change 02/17/94 by Brian Lomasky ----- ! SUB FIND_IDENTIFIER(WORD RIGHTSLIST_FILE_INDEX) %INCLUDE "NUSER.INC" DECLARE WORD ERR_FLAG ! TRUE IF DONE READING RIGHTS DECLARE LONG HELD_IDENT_INDEX ! HELD IDENTIFIER ARRAY INDEX DECLARE WORD MATCHING_HELD_IDENT! TRUE IF MATCHING HELD IDENT DECLARE LONG TEMP_LONG ! TEMPORARY LONGWORD VARIABLE DECLARE STRING TEMP_STRING ! TEMPORARY STRING EXTERNAL WORD FUNCTION SEARCH_RIGHTSLIST(WORD, WORD, & WORD) ! READ MATCHING RIGHTSLIST REC MAP (FINDIDENTMAP) STRING SEARCH_HOLDER_STRING = 8% DIV = " " ! ASSUME NO DIVISION CODE DIVISION_ACCESS = " " ! ASSUME NO DIVISIONAL ACCESS ! ----- VALIDATE USERNAME ----- TEMP_STRING = TRM$(USER_NAME) IF DEBUG_MODE THEN PRINT "DEBUG>FIND_IDENTIFIER for " + & TEMP_STRING + " in rightslist on " + & TRM$(RIGHTSLIST_NODES(RIGHTSLIST_FILE_INDEX)) END IF ! ----- ERROR IF USERNAME IS TOO LONG ----- IF LEN(TEMP_STRING) < 1% OR LEN(TEMP_STRING) > 12% THEN PRINT PRINT "Error - Username argument is" + & " out of range: " + TEMP_STRING + BEL PRINT EXIT SUB END IF ! ----- SEARCH SPECIFIED RIGHTSLIST.DAT FILE BY ITS ----- ! ----- ALTERNATE KEY #2 TO CHECK FOR A VALID USERNAME ----- KGB_NAME = TEMP_STRING ! STORE USERNAME TO SEARCH FOR IF NOT SEARCH_RIGHTSLIST(RIGHTSLIST_FILE_INDEX, 2%, FALSE) THEN EXIT SUB END IF ! ----- ERROR IF NOT IN UIC FORMAT ----- IF KGB_IDENTIFIER < 0% OR KGB_HOLDER(0%) <> 0% THEN ! ----- PRINT ERROR IF IDENTIFIER IS NOT A ----- ! ----- USERNAME ----- PRINT PRINT "Error - " + TEMP_STRING + & " is not a username - it's an identifier" + BEL PRINT EXIT SUB END IF ! ----- SAVE THIS USER'S UIC AND USE AS THE SEARCH KEY ----- KGB_HOLDER(0%) = KGB_IDENTIFIER KGB_HOLDER(1%) = 0% ! ----- SAVE IN TEMP STRING ----- SEARCH_HOLDER_STRING = KGB_HOLDER_STRING IF DEBUG_MODE THEN PRINT "DEBUG>FIND_IDENTIFIER: Locate key #1 GE "& + NUM1$(KGB_IDENTIFIER) END IF ! ----- LOCATE FIRST HOLDER RECORD FOR THIS IDENTIFER ----- ! ----- RECORD ----- ERR_FLAG = FALSE ! INIT END-OF-FILE FLAG WHEN ERROR IN GET #RIGHTSLIST_FILE_INDEX, KEY #1% GE & SEARCH_HOLDER_STRING, REGARDLESS USE IF ERR = BUCKET_LOCKED THEN SLEEP 1% RETRY END IF EXIT HANDLER IF ERR <> END_OF_FILE AND & ERR <> REC_NOT_FOUND ERR_FLAG = TRUE ! SET END-OF-FILE FLAG CONTINUE ! AND CONTINUE AFTER HANDLER END WHEN ! ----- FIND ALL HELD IDENTIFIERS FOR THIS HOLDER UIC ----- WHILE NOT ERR_FLAG ! UNTIL END-OF-FILE REACHED: ! ----- DONE IF HOLDER UIC DOES NOT MATCH ----- IF SEARCH_HOLDER_STRING <> KGB_HOLDER_STRING THEN IF DEBUG_MODE THEN PRINT "DEBUG>FIND_IDENTIFIER:" + & " Exit - EOF" PRINT "DEBUG> Ident Value is " +& NUM1$(KGB_IDENTIFIER) PRINT "DEBUG> Holder Value is " & + NUM1$(KGB_HOLDER(0%)) & + " " + NUM1$(KGB_HOLDER(1%)) END IF ERR_FLAG = TRUE ! SET END-OF-FILE FLAG ITERATE ! EXIT LOOP END IF ! ----- WE FOUND A HELD IDENTIFIER RECORD ----- ! ----- SKIP IF NOT UNIQUE ----- MATCHING_HELD_IDENT = FALSE HELD_IDENT_INDEX = 0% WHILE HELD_IDENT_INDEX < HELD_IDENTS_CTR HELD_IDENT_INDEX = HELD_IDENT_INDEX + 1% IF KGB_IDENTIFIER = HELD_IDENTS( & HELD_IDENT_INDEX) THEN MATCHING_HELD_IDENT = TRUE END IF NEXT IF MATCHING_HELD_IDENT THEN IF DEBUG_MODE THEN PRINT "DEBUG>Skip dupl value " & + NUM1$(KGB_IDENTIFIER) END IF ELSE ! ----- INCR COUNT OF HELD IDENTIFIERS ----- HELD_IDENTS_CTR = HELD_IDENTS_CTR + 1% ! ----- STORE HELD IDENTIFIER VALUE ----- HELD_IDENTS(HELD_IDENTS_CTR) = KGB_IDENTIFIER IF DEBUG_MODE THEN PRINT "DEBUG> Held ident #" + & NUM1$(HELD_IDENTS_CTR) & + " value is " + & NUM1$(KGB_IDENTIFIER) END IF END IF ! ----- READ NEXT HOLDER RECORD ----- IF DEBUG_MODE THEN PRINT "DEBUG> Get Next" END IF WHEN ERROR IN GET #RIGHTSLIST_FILE_INDEX, REGARDLESS USE IF ERR = BUCKET_LOCKED THEN SLEEP 1% RETRY END IF EXIT HANDLER IF ERR <> END_OF_FILE AND & ERR <> REC_NOT_FOUND ERR_FLAG = TRUE ! SET END-OF-FILE FLAG CONTINUE ! AND CONTINUE AFTER HANDLER END WHEN NEXT ! ----- NOW GO LOOKUP EACH OF THE HELD IDENTIFIER ----- ! ----- DESCRIPTIONS ----- IF DEBUG_MODE THEN PRINT "DEBUG>FIND_IDENTIFIER: Found " + & NUM1$(HELD_IDENTS_CTR) + " idents" PRINT "DEBUG>FIND_IDENTIFIER: Lookup ident descs" END IF HELD_IDENT_INDEX = 0% WHILE HELD_IDENT_INDEX < HELD_IDENTS_CTR HELD_IDENT_INDEX = HELD_IDENT_INDEX + 1% IF DEBUG_MODE THEN PRINT "DEBUG>Lookup identifier #" + & NUM1$(HELD_IDENT_INDEX) END IF KGB_IDENTIFIER = HELD_IDENTS(HELD_IDENT_INDEX) ! ----- LOOKUP IDENTIFIER NAME ON DESIRED NODE ----- IF NOT SEARCH_RIGHTSLIST(RIGHTSLIST_FILE_INDEX, & 0%, FALSE) THEN ! ----- REMOVE THIS BAD IDENTIFIER FROM ----- ! ----- MEMORY LIST ----- IF DEBUG_MODE THEN PRINT "DEBUG>No matching Desc - Remove" END IF TEMP_LONG = HELD_IDENT_INDEX WHILE TEMP_LONG < HELD_IDENTS_CTR HELD_IDENTS(TEMP_LONG) = & HELD_IDENTS(TEMP_LONG + 1%) HELD_IDENTS_STR(TEMP_LONG) = & HELD_IDENTS_STR(TEMP_LONG + 1%) TEMP_LONG = TEMP_LONG + 1% NEXT HELD_IDENTS_CTR = HELD_IDENTS_CTR - 1% HELD_IDENT_INDEX = HELD_IDENT_INDEX - 1% ITERATE END IF ! ----- STORE HELD IDENTIFIER STRING ----- HELD_IDENTS_STR(HELD_IDENT_INDEX) = TRM$(KGB_NAME) IF DEBUG_MODE THEN PRINT "DEBUG> Held ident #" + & NUM1$(HELD_IDENT_INDEX) + & " name is " + TRM$(KGB_NAME) END IF ! ----- VERIFY THAT IDENTIFIER NAME EXISTS ON ----- ! ----- THE LOCAL NODE ----- IF RIGHTSLIST_FILE_INDEX <> 1% THEN IF NOT SEARCH_RIGHTSLIST(1%, 0%, FALSE) THEN PRINT "Warning - Skipping" + & " identifier which is" +& " not defined on" + & " this node: " + & HELD_IDENTS_STR( & HELD_IDENT_INDEX) + BEL ! ----- REMOVE THIS BAD IDENTIFIER ----- ! ----- FROM MEMORY LIST ----- TEMP_LONG = HELD_IDENT_INDEX WHILE TEMP_LONG < HELD_IDENTS_CTR HELD_IDENTS(TEMP_LONG) & = HELD_IDENTS( & TEMP_LONG + 1%) HELD_IDENTS_STR( & TEMP_LONG) = & HELD_IDENTS_STR(& TEMP_LONG + 1%) TEMP_LONG = TEMP_LONG + 1% NEXT HELD_IDENTS_CTR = HELD_IDENTS_CTR - 1% HELD_IDENT_INDEX = HELD_IDENT_INDEX - 1% ITERATE END IF ! ----- ERROR IF IDENTIFIER STRINGS DO ----- ! ----- NOT MATCH ----- IF HELD_IDENTS_STR(HELD_IDENT_INDEX) <> & TRM$(KGB_NAME) THEN PRINT "Error - Skipping" + & " identifier which" + & " has a different" + & " value on the two nodes:" PRINT " Local node: " + & TRM$(KGB_NAME) PRINT " Node " + & TRM$(RIGHTSLIST_NODES( & RIGHTSLIST_FILE_INDEX)) & + ": " + & HELD_IDENTS_STR( & HELD_IDENT_INDEX) PRINT "Please Notify your" + & " VAX System Manager" + BEL END IF END IF ! ----- SKIP IF WE'VE ALREADY FOUND A DIVISIONAL ----- ! ----- IDENTIFIER ----- ITERATE IF DIV <> " " ! ----- SKIP IF NOT A DIVISIONAL IDENTIFIER ----- ITERATE IF LEN(TRM$(KGB_NAME)) <> 4% ITERATE IF POS("RWU", MID(KGB_NAME, 4%, 1%), 1%) = 0% ! ----- EXTRACT DIVISIONAL IDENTIFIER ----- DIV = LEFT(KGB_NAME, 3%) ! ----- EXTRACT DIVISIONAL-SPECIFIC ACCESS ----- DIVISION_ACCESS = MID(KGB_NAME, 4%, 1%) NEXT IF DEBUG_MODE THEN PRINT "DEBUG> Done - DIV is " + DIV + & ", Division access is " + DIVISION_ACCESS END IF IF DIV = " " THEN ! IF NO DIVISION CODE FOUND: DIV = "OTH" ! DEFAULT THE DIVISION CODE DIVISION_ACCESS = "U" ! DEFAULT THE DIVISIONAL ACCESS END IF END SUB