Appendix C: RACF Userid Conversion Script

 < Day Day Up > 



The following REXX exec was used in 7.5.6, "Mass-exporting RACF users to LDAP" on page 313 to convert exported RACF userids to LDAP entries.

Example C-1: CONVLDIF REXX program listing

start example
 /**************************** REXX ***********************************/ /* CONVLDIF: Merge an exported RACF user list file and a LDIF        */ /*           template file to an ldif file for Portal Server         */ /*                                                                   */ /*********************************************************************/ /* Usage:                                                            */ /*                                                                   */ /* 1. Use an LDIF Browser to export RACF userds to a file. The file  */ /*    will contains dn: racfid=USERXXX,profiletype=USER, o=YYYYYY.   */ /* 2. Create a templete file with correct ldif format.               */ /* 3. Replace the name specified in uid of dn:, givenname,           */ /*    ibm-natived, sn, name portion of the mail, uid and cn fileds   */ /*    with #racfid1, #racfid2 or #racfid3.                           */ /*    #racfid1: Uppercase, #racfid2: lowercase, and #racfid3: first  */ /*    letter uppercase.                                              */ /* 4. Create an empty output file.                                   */ /* 5. Match all the three file names with this REXX script.          */ /*  . Replace <YourHLQ> to your selected datasets pefix (ie. JAVA1)  */ /* 6. Run this REXX script and the outpit file will have the merged  */ /*   ldif format.                                                    */ /*                                                                   */ /*********************************************************************/ /*  Date    who    COMMENT                                           */ /* ------- ----- --------------------------------------------------  */ /* 5/29/03  CCC  Created                                             */ /*                                                                   */ /*********************************************************************/ /*  step1: Get input file names                                      */  "free fi(INDD1)"  "free fi(INDD2)"  "free fi(OUTDD1)"  infile1  = "<YourHLQ>.TEMPLATE.INPUT"  infile2  = "<YourHLQ>.RACFID.INPUT"  outfile1 = "<YourHLQ>.MERGED.OUTPUT"  "alloc fi(INDD1) da('"infile1"') shr reuse"  "alloc fi(INDD2) da('"infile2"') shr reuse"  "alloc fi(OUTDD1) da('"outfile1"') shr reuse"  EOFFLAG1 = 2              /* return code to indicate end-of-file    */  RETURN_CODE1 = 0           /* initialize return code                         */ "EXECIO 0 DISKR INDD1 (OPEN"      /* open template file           */ "EXECIO 0 DISKR INDD2 (OPEN"      /* open table                   */ "EXECIO 0 DISKW OUTDD1 (OPEN"     /* open outout file             */ /*----------------------------------------------------------------*/ /*  step2:  read in the template file                             */ /*----------------------------------------------------------------*/  bPattern = 'racfid='                 /* Begin pattern           */  ePattern = ','                       /* End pattern             */  token = '#racfid'                    /* Token to be replaced    */  nTotal = 0            /* Total template lines  */  lSeg.  = ''           /* Left  Segment of the template line */  rSeg.  = ''           /* Right segment of the template line */  lineMerge. = 0        /* Default to no merger for this line */  Name_case. = 1        /* set default to upper case */  junk   = ''; s1 =''; s2= ''; s3= ''  Case   = 0                           /* Case = 1, 2, or 3 */  strUpper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' /* Translate table in  */  strLower = 'abcdefghijklmnopqrstuvwxyz' /* Translate table out */      N = 0                  /* template line counter */      P = 0                  /* #racfid location      */      ALINE = ''             /* init */  say ''  say " *** Start to read template list file ... "  say ''  /*----------------------------------------------------------------*/  nTotal = 0             /* Total template lines */  lSeg.  = ''            /* Left  Segment of the template line */  rSeg.  = ''            /* Right segment of the template line */  lineMerge. = 0         /* Default to no merger for this line */  Name_case. = 1         /* set default to upper case */  junk   = ''; s1 =''; s2= ''; s3= ''  Case   = 0                            /* Case = 1, 2, or 3 */  token1= 'racfid='                        /* locate racfid=      */  token = '#racfid'                        /* Replace with racfid */  strUpper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'  /* Translate table in  */  strLower = 'abcdefghijklmnopqrstuvwxyz'  /* Translate table out */     N = 0                  /* template line counter */     P = 0                  /* #racfid location      */     ALINE = ''             /* init */  say ''  say " Start to read template list file ... "  say ''  DO WHILE (RETURN_CODE1 \= EOFFLAG1) /* loop while not end-of-file   */    'EXECIO 1 DISKR INDD1'           /* read 1 line from template    */    RETURN_CODE1 = RC                 /* save execio rc                    */     IF RETURN_CODE1 = 0 THEN         /* get a line ok?       */       DO                             /* yes                  */         N = N + 1                    /* Line counter         */         PARSE PULL ALINE         P = POS(TOKEN,ALINE,1)       /* Get TOKEN location */         IF (P \= 0) THEN             /* IF a token is found */            DO              lineMerge.N = 1         /* Will merge this line */              PARSE VAR ALINE lSeg.N =(P) JUNK +7 Case +1 rSeg.N              SELECT                  /* -----Start Select ----- */                 WHEN Case = '1' THEN                 DO                    Name_case.N = 1     /* uppercase  */                 END               WHEN Case = '2' THEN                 DO                    Name_case.N = 2     /* lowercase  */                 END               WHEN Case = '3' THEN                 DO                    Name_case.N = 3     /* first letter uppercase */                 END               OTHERWISE                 DO                    Name_case.N = 1    /* case defult to upper */                 END            END                   /* ----- End of select ----- */          END    /* ----- End of DO for If (p \= 0) then ------*/       ELSE      /* ---- ELSE of        If (p \= 0) then ------*/          DO             lSeg.N = ALINE        /* save the line unchanged  */             lineMerge.N = 0       /* set lineMerger flag to 0 */           END       END      /*- End of DO for IF (RETURN_CODE1 \= 0) THEN -*/     ELSE       DO           IF (RC \= 2) THEN           DO           SAY "TEMPLATE FILE "||(INFILE1)||" READ ERROR !"           SAY 'RC=' RC           EXIT 3           END           ELSE NOP        END  END       nTotal = N                   /* TOTAL TEMPLATE LINES */       N = 0               /* RACF ldif Input file counter */       R = 0               /* # of racfid= lines found     */       rPart = ''          /* init */  say ''  say " Start to read racfid list file ... "  say ''  /*----------------------------------------------------------------*/  /*  step3: read in the RACF racfid list file                      */  /*----------------------------------------------------------------*/    RETURN_CODE1 = 0         /* INITIALLZE RETURN CODE                */  DO WHILE (RETURN_CODE1 \= EOFFLAG1) /* loop while not end-of-file  */     'EXECIO 1 DISKR INDD2'           /* read 1 line from table file */     RETURN_CODE1 = RC                /* save execio rc                   */     IF RETURN_CODE1 = 0 THEN         /* get a line ok?              */        DO                            /* yes                         */          N = N + 1                   /* Total line counter          */          PARSE PULL ALINE          P1 = POS(TOKEN1,ALINE,1)    /* FIND first 'racfid=' */          IF (P1 \=0) THEN            /* Yes                 */            DO              PARSE VAR ALINE JUNK =(P1) rPart              P2 = POS(',',rPart,1)              PARSE VAR rPart JUNK2 +7 name =(P2) JUNK1              RACFID = STRIP(name)     /* clean the blanks */              uname = RACFID           /* save racfid to uname */               R = R + 1             /* 'racfid=' line counter */  /* --> WRITE OUT THE MERGED Output to file */          DO K = 1 TO nTotal        /* loop though all template lines */            ALINE1 = ''             /* Init the output line */            IF (lineMerge.K \= 0) THEN              DO                Case = Name_case.K   /* User Name case type */                SELECT             /* Strat of the select   */                  WHEN Case = 1 THEN                    DO                      Upper uname                    END                  WHEN Case = 2 THEN                    DO                       s3 = uname      /* change it to lower case */                       uname = TRANSLATE(s3,strLower,strUpper)                    END                  WHEN Case = 3 THEN                    DO                       PARSE VAR uname s1 +1 s2                       Upper s1                                          /* change it to lowercase */                       s3 = TRANSLATE(s2,strLower,strUpper)                       uname = (s1)||(s3)                    END                  OTHERWISE                    DO                    Upper uname                 END             END      /* ----- End of select ----- */             ALINE1 = lSeg.K||uname||rSeg.K          END         /* ------ End of DO ---- */        ELSE          DO             ALINE1 = lSeg.K          END         /* ------ End of ELSE ---- */        PUSH ALINE1        'EXECIO 1 DISKW OUTDD1'  /* write aline to tsscmd file */        END      /* ----- End of DO K = 1 ----- */        ALINE1 = ''              /* Write a blank line */        PUSH ALINE1        'EXECIO 1 DISKW OUTDD1'       END      /* ----- End of IF (P1 \= 0) THEN DO ----*/       ELSE NOP      END      /* ===== End of IF (RETTURN_CODE1 = 0) =====*/    ELSE      DO         IF (RC \= 2) THEN         DO           SAY "RACF FILE "||(INFILE2)||" LINE# "||(N)||" ERROR !"           EXIT 4         END         ELSE NOP      END   END           /* ------- End of do while ------- */   nInlines = N   nRacfids = R  say ''  say "Total Input File lines: "||(nInlines)||" "  say "Total racfid= lines   : "||(nRacfids)||" "  say ''  "EXECIO 0 DISKR INDD1 (FINIS"        /* close the input file  */  "EXECIO 0 DISKR INDD2 (FINIS"        /* close the input file  */  "EXECIO 0 DISKW OUTDD1 (FINIS"       /* close the output file  */  "FREE FI(INDD1)"  "FREE FI(INDD2)"  "FREE FI(OUTDD1)"  exit 
end example



 < Day Day Up > 



Websphere Portal on Z. OS
Websphere Portal on Z/OS
ISBN: 0738499382
EAN: 2147483647
Year: 2003
Pages: 90

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net