$! ACCT_ADDUSER.COM $! $! Author: L Baldwin 10-Jun-93 $! Desc: $! Command procedure to add a new user account $ on controly then goto bad_message $ @TASM$COM:TASM_MENUSYM ! Define common symbols $ SET NOON $ max_username_len = 12 $! Add you template names below (leave first entry blank) $ tmpl_name = "//TMPL_EXEC/TMPL_BILL/TMPL_HR/TMPL_SHIP/TMPL_SYST/" $! Define default login device, UIC group, and description $ tmpl_dev = "//DSK$EXECUTIVE/DSK$BILLING/DSK$HR/DSK$SHIPPING/DSK$SYSTEMS/" $ tmpl_grp = "//100/200/400/600/700/" $ tmpl_desc = "//Executive/Billing/Human Resources/Shipping/Systems/" $MAIN_MENU: $ type sys$input A D D U S E R A C C O U N T 1 - RETURN Return to previous menu $! $! Display all available templates $! $ n = 2 $TMPL_LOOP: $ name = f$element(n,"/",tmpl_name) $ desc = f$element(n,"/",tmpl_desc) $ if name .eqs. "" then goto GET_TMPL $ out = f$fao(" !2UL - !10AS !40AS",n,name,desc) $ say out $ n = n + 1 $ goto TMPL_LOOP $GET_TMPL: $ say " " $ inquire/nopun type "Enter account template to use: " $ if type .eqs. "" then exit $ if (type .lt. 1 .or. type .gt. n) then goto MAIN_MENU $ if type .eq. 1 then EXIT $ tmpl = f$element(type,"/",tmpl_name) $ grp = f$element(type,"/",tmpl_grp) $ dev = f$element(type,"/",tmpl_dev) $! $! on warning then goto cleanup $ prevpriv = f$setprv("SYSPRV") $ if .not. f$priv("SYSPRV") then goto nopriv $ write sys$output "" $ inquire last_name "Last name" $ inquire first_name "First name" $ inquire middle_name "Middle initial" $ full_name = first_name+" "+middle_name+". "+last_name $! $! Build a unique Username $! $ length=0 $ name_length = f$length(last_name) $ temp_last_name = last_name $ if name_length .gt. max_username_len then - temp_last_name=f$extract(0,max_username_len-1,last_name) $BUILD_USERNAME: $ length = length + 1 $ if name_length+length .gt. max_username_len $ then $ say "Cannot build unique username because similar names already exist." $ say "You must add this account manually." $ exit $ endif $! Add letters from first name $ username = temp_last_name+f$extract(0,length,first_name) $ set message/nof/noi/nos/not ! Turn off error messages $ define/user sys$output nl: $ uaf SHOW 'username' ! see if already exists $ saved_severity = $severity $ set message/f/i/s/t ! Turn msgs on $ if saved_severity .ne. 2 then goto BUILD_USERNAME ! Try again $display_UIC_members: $ uaf show ['grp',*]/brief $ if $severity .gt. 1 then say- "There are no group members, use any number you wish." $ write sys$output "" $ goto get_member $GET_MEMBER: $ say "Chose a UIC Member number, excluding the ones listed above." $ say " " $ inquire membr "Account's UIC Member number" $ if((membr .eqs. "?").or.(membr .eqs. "")) then goto display_UIC_members $ ! $ ! Combine group and member numbers to create complete UIC $ ! in the form - [group,member] $ ! $CREATE_UIC: $ uic = "[" + grp + "," + membr + "]" $ ! $ ! Create new user directory. Create new account. $ ! $CREATE_ACCOUNT: $ create/dir/owner='uic'/prot=(s:rwe,o:rwe,g:re,w) - 'dev':['username']/LOG $ uaf COPY 'tmpl' 'username'/owner="''full_name'"- /dir=['username']/uic='uic'/password='username' $ on controly then goto good_message $ UAF SHOW 'username' $ say "" $ say "Account added." $ goto DONE $good_message: $ say "" $ say "Program halted by control_y, account WAS already been created." $ say "" $ goto done $bad_message: $ say "" $ say "Program halted by control_y, account was NOT yet been created." $ say "" $ goto done $nopriv: $ say "You need SETPRV or SYSPRV privilege to run this procedure" $DONE: