Trucs et Astuces - AS400 - Tips and Tricks

page d'accueil   Boite à outils

 

OBJOWN - Corriger propriétaire et autorisations Table des matières

traite tous les objets d'une bibliothèque

/* OBJOWN */
CMD PROMPT('Propriété et Autorisations')

PARM KWD(LIBRARY) TYPE(*CHAR) LEN(10) MIN(1) +
PROMPT('Bibliothèque')

PARM KWD(OWNER) TYPE(*CHAR) LEN(10) MIN(1) +
PROMPT('Propriétaire')

PARM KWD(SECOFR) TYPE(*CHAR) LEN(04) RSTD(*YES) +
DFT(*YES) VALUES(*YES *NO) +
PROMPT('Préserver acquisition droits')

PARM KWD(PUBLICAUT) TYPE(*CHAR) LEN(10) +
RSTD(*YES) DFT(*EXCLUDE) VALUES(*CHANGE +
*ALL *USE *EXCLUDE) PROMPT('Droit accordé +
à *PUBLIC')

/* OBJOWNC */
/* COMPILER EN USRPRF(*OWNER), PROPRIETE DE QSECOFR */
/* QSECOFR NECESSAIRE POUR CHGOBJOWN DES PGM EN USRPRF(*OWNER) */

PGM PARM(&LIB &OWN &OFR &AUT)
/* &SOURCE : PREFIXE BIBLIOTHEQUE SOURCE */
/* */
/* BIBLIOTHEQUE DANS LAQUELLE LES OBJETS DOIVENT CHANGER DE PROPRIO */
DCL VAR(&LIB) TYPE(*CHAR) LEN(10)
/* NOUVEAU PROPRIETAIRE */
DCL VAR(&OWN) TYPE(*CHAR) LEN(10)
DCL VAR(&OFR) TYPE(*CHAR) LEN(4)
/* DROIT *PUBLIC */
DCL VAR(&AUT) TYPE(*CHAR) LEN(10)
/* */
DCLF FILE(QSYS/QADSPOBJ)
/* */
IF COND(&AUT *EQ ' ') THEN(DO)
CHGVAR VAR(&AUT) VALUE('*EXCLUDE')
ENDDO
/* */
/* ********* CHGJOB LOGCLPGM(*NO) */
/* */
/* VERIFICATION D'EXISTENCE DE LA BIBLIOTHEQUE */
/* */
CHKOBJ OBJ(QSYS/&LIB) OBJTYPE(*LIB)
MONMSG MSGID(CPF0000) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('La +
bibliothèque QSYS/' *TCAT &LIB *BCAT +
'n''existe pas, fin de traitement') +
MSGTYPE(*ESCAPE)
ENDDO
/* */
/* VERIFICATION D'EXISTENCE DU NOUVEAU PROPRIETAIRE */
/* */
CHKOBJ OBJ(&OWN) OBJTYPE(*USRPRF)
MONMSG MSGID(CPF0000) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Le +
profil' *BCAT &OWN *BCAT 'n''existe pas, +
fin de traitement') MSGTYPE(*ESCAPE)
ENDDO

/* CONSTITUTION FICHIER DE TOUS LES OBJETS DE LA BIBLIOTHEQUE */
DSPOBJD OBJ(&LIB/*ALL) OBJTYPE(*ALL) +
DETAIL(*SERVICE) OUTPUT(*OUTFILE) +
OUTFILE(QTEMP/LIBOBJOWN)
MONMSG MSGID(CPF2123) EXEC(GOTO CMDLBL(FINOWN)) /* +
Bibliothèque vide */
OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/LIBOBJOWN) +
SHARE(*YES)
/* NETTOYER LES AUTORISATIONS */
RVKOBJAUT OBJ(&LIB/*ALL) OBJTYPE(*ALL) USER(*ALL) +
AUT(*ALL)
MONMSG MSGID(CPF0000) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('Incidents lors de la révocation +
des droits sur les objets. Incidents +
ignores') TOPGMQ(*EXT) MSGTYPE(*DIAG)
ENDDO
/* LECTURE FICHIER DE TOUS LES OBJETS A TRAITER */

BOUCLE: RCVF
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(FINOWN))

/* TRAITEMENT DES OBJETS */
/* SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('l''objet' *BCAT &ODLBNM *TCAT '/' +
*TCAT &ODOBNM *BCAT 'appartient à' *BCAT +
&ODOBOW) TOPGMQ(*EXT) MSGTYPE(*STATUS) */
/* 1 */ IF COND(&ODOBNM *NE ' ') THEN(DO)
/* GESTION DE LA PROPRIETE */
/* 2 */ IF COND(&ODOBOW *NE &OWN) THEN(DO)
/* SI C'EST UN *PGM, ET OWNER=QSECOFR, */
/* FAIRE GRTOBJAUT LE-GROUPE *ALL */
/* AU LIEU DE CHGOBJOWN LE-GROUPE */
/* */
IF COND(&ODOBTP *EQ '*PGM' *AND (&ODOBOW *EQ +
'QSECOFR' *OR &ODOBOW *EQ 'QSYSOPR') *AND +
&OFR *EQ '*YES') THEN(DO) /* 3 */
GRTOBJAUT OBJ(&LIB/&ODOBNM) OBJTYPE(&ODOBTP) +
USER(&OWN) AUT(*ALL)
ENDDO
ELSE CMD(DO)
CHGOBJOWN OBJ(&LIB/&ODOBNM) OBJTYPE(&ODOBTP) NEWOWN(&OWN)
/* 3 */ ENDDO
/* 2 */ ENDDO
/* GESTION DES AUTORISATIONS */
/* SI C'EST UN *LIB OU UN *JOBD, ALORS AUT >= *USE */
/*2*/ IF (&AUT *EQ '*EXCLUDE') THEN(DO)
/*3*/ IF (&ODOBTP *EQ '*LIB' *OR &ODOBTP *EQ '*JOBD') THEN(DO)
GRTOBJAUT OBJ(&LIB/&ODOBNM) OBJTYPE(&ODOBTP) +
USER(*PUBLIC) AUT(*USE)
/*4*/ MONMSG MSGID(CPF0000) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('Incident GRTAUT' *BCAT &ODLBNM +
*TCAT '/' *TCAT &ODOBNM *BCAT &ODOBTP +
*BCAT '*PUBLIC *USE. Incidents ignores') +
TOPGMQ(*EXT) MSGTYPE(*DIAG)
/*4*/ ENDDO
/*3*/ ENDDO
/*2*/ ENDDO
/*2*/ ELSE DO
GRTOBJAUT OBJ(&LIB/&ODOBNM) OBJTYPE(&ODOBTP) +
USER(*PUBLIC) AUT(&AUT)
/*3*/ MONMSG MSGID(CPF0000) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('Incident GRTAUT' *BCAT &ODLBNM +
*TCAT '/' *TCAT &ODOBNM *BCAT &ODOBTP +
*BCAT '*PUBLIC' *BCAT &AUT *BCAT '. +
Incidents ignores') TOPGMQ(*EXT) +
MSGTYPE(*DIAG)
/*3*/ ENDDO
/*2*/ ENDDO


/* 1 */ ENDDO
/* */

GOTO BOUCLE
FINOWN:
/* */
/* */
/* LA MEME CHOSE SUR L'OBJET BIBLIOTHEQUE */
/* */
/* */
CHGOBJOWN OBJ(QSYS/&LIB) OBJTYPE(*LIB) NEWOWN(&OWN)
RVKOBJAUT OBJ(QSYS/&LIB) OBJTYPE(*LIB) USER(*ALL) +
AUT(*ALL)
CHGLIB LIB(&LIB) CRTAUT(&AUT)
IF COND(&AUT *EQ '*EXCLUDE') THEN(DO)
GRTOBJAUT OBJ(QSYS/&LIB) OBJTYPE(*LIB) USER(*PUBLIC) +
AUT(*USE)
ENDDO
ELSE CMD(DO)
GRTOBJAUT OBJ(QSYS/&LIB) OBJTYPE(*LIB) USER(*PUBLIC) +
AUT(&AUT)
ENDDO
FINPGM:
ENDPGM

The source code is provided as an open source tool under the GNU General Public License, version 2.  In summary, this license specifies:

By clicking the download link you acknowledge and agree to the terms of the license.

Download the (zipped) SAVF containing the JPLTOOLS : the source file, the message file, the bnddir

THIS TOOLBOX IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROVIDER OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS TOOLBOX, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.