/****************************************************************************** ** PROGRAM: genusrcsv.p ** PURPOSE: Generate usr.csv for creating Windows Users ** CREATOR: Patrick Swanson (ips) ** CREATED: 06/23/2010 *******************************************************************************/ def var w-passwd as char format "x(10)" no-undo. def var w-comment as char format "x(10)" no-undo. def var w-char as char no-undo. def var w-cntr as inte no-undo. def var w-upper as inte no-undo. def var w-lower as inte no-undo. def var w-integ as inte no-undo. update w-comment label "Comment" help "Enter comment to add to each NT user" with center side-label. output to usr.csv. for each usr_mstr no-lock where usr_mstr.usr_active and not usr_mstr.usr_userid begins "od" and not usr_mstr.usr_userid begins "qad" and not usr_mstr.usr_userid begins "qxi" and not usr_mstr.usr_userid = "mfg" and not usr_mstr.usr_userid = "batchjob": input thru value("odrepos/py/genpasswd.py") no-echo. import ^ ^ w-passwd. input close. /* REPLACE EASILY MISTAKEN CHARACTERS */ assign w-passwd = replace(w-passwd,"O","o") w-passwd = replace(w-passwd,"I","i") w-passwd = replace(w-passwd,"l","L") w-passwd = replace(w-passwd,"0",string(random(2,9))) w-passwd = replace(w-passwd,"1",string(random(2,9))) . /* COUNT UPPER/LOWER/INTERGER CHARACTERS */ assign w-upper = 0 w-lower = 0 w-integ = 0 . do w-cntr = 1 to length(w-passwd): assign w-char = substring(w-passwd,w-cntr,1) . if asc(w-char) > 64 and asc(w-char) < 91 then assign w-upper = w-upper + 1 . else if asc(w-char) > 47 and asc(w-char) < 58 then assign w-integ = w-integ + 1 . else assign w-lower = w-lower + 1 . end. do w-cntr = 1 to length(w-passwd) while w-upper < 2: assign w-char = substring(w-passwd,w-cntr,1) . if w-char <> "O" and w-char <> "I" and w-char >= "a" and w-char <= "z" then assign substring(w-passwd,w-cntr,1) = caps(w-char) w-upper = w-upper + 1 w-lower = w-lower - 1 . end. do w-cntr = length(w-passwd) to 1 by -1 while w-lower < 2: assign w-char = substring(w-passwd,w-cntr,1) . if w-char <> "L" and w-char >= "a" and w-char <= "z" then assign substring(w-passwd,w-cntr,1) = lc(w-char) w-upper = w-upper - 1 w-lower = w-lower + 1 . end. /* ADD 9'S TO COMPLETE INTEGER REQUIREMENTS */ if w-integ < 2 then do w-cntr = 1 to (2 - w-integ): assign w-passwd = w-passwd + string(random(2,9)) . end. put unformatted usr_mstr.usr_userid "," w-passwd "," usr_mstr.usr_name . put unformatted (if w-comment > "" then ("," + w-comment) else "") skip. end. output close. unix silent value("odrepos/windows/scripts/new-Win-group.awk > group.bat"). unix silent value("odrepos/windows/scripts/new-Win-user.awk > user.bat"). unix silent value("unix2dos group.bat"). unix silent value("unix2dos user.bat").