How can I list all objects on a system owned by named user. (I am trying to track where a certain user has made changes in the past (years ago..), and I want this to be part of the analysis.
I would like to have a parameter 'OWNER' on the DSPOBJD command, but its not there.
System to be analysed is a 3TB system with many apps, and its running 24-7, so a total DSPOBJD to an outfile is NOT a valid solution in this case.
Any ideas on this will be most apreciated.
DanF
Software/Hardware used:
IBM System i (Power 6) V6R1
ASKED:
December 14, 2010 7:53 AM
UPDATED:
April 28, 2011 5:47 PM
Vervina,
WRKOBJOWN does not run in batch (as far as I can read). Would be nice if the command had an *OUTFILE option and was allowed for batch processing.
DanF
I use the DSPUSRPRF command and ask for Owned objects.
I then put the info to an output file which I can manipulate in query, etc
User profile . . . . . . . . . . > *ALL Name, generic*, *ALL
Type of information . . . . . . > *OBJOWN *BASIC, *ALL, *CMDAUT..
Output . . . . . . . . . . . . . > *OUTFILE *, *PRINT, *OUTFILE
File to receive output . . . . . usertemp Name
Library . . . . . . . . . . . XXXXXXX Name, *LIBL, *CURLIB
Output member options:
Member to receive output . . . *FIRST Name, *FIRST
Replace or add records . . . . *REPLACE *REPLACE, *ADD
Dan,
I did something similar to KasMcc, here is part of my CL;
PGM PARM(&USRPRF)
DCLF FILE(QSYS/QADSPUPO) RCDFMT(QSYDSUPO)
DCL VAR(&USRPRF) TYPE(*CHAR) LEN(10)
DSPUSRPRF USRPRF(&USRPRF) TYPE(*OBJOWN) +
OUTPUT(*OUTFILE) OUTFILE(QTEMP/QADSPUPO)
OVRDBF FILE(QADSPUPO) TOFILE(QTEMP/QADSPUPO) +
POSITION(*RRN 1) SHARE(*YES)
Hope this helps,
Bill Poulin
Assuming that you only care about /QSYS.LIB, DSPUSRPRF *OBJOWN is probably sufficient. If you really need to know a complete list of a user’s owned objects, you’ll need to use the List Objects User Is Authorized to, Owns, or Is Primary Group of (QSYLOBJA) API.
You’ll need to call the API twice (at least), once for format OBJA0100 and again for format OBJA0110.
Tom
Try this..
User profile . . . . . . . . . . > *ALL Name, generic*, *ALL
Type of information . . . . . . > *OBJOWN *BASIC, *ALL, *CMDAUT..
Output . . . . . . . . . . . . . > *OUTFILE *, *PRINT, *OUTFILE
File to receive output . . . . . usertemp Name
Library . . . . . . . . . . . XXXXXXX Name, *LIBL, *CURLIB
Output member options:
Member to receive output . . . *FIRST Name, *FIRST
Replace or add records . . . . *REPLACE *REPLACE, *ADD
U can save this information in outfile, and can use it accordingly
Ddaswani,
Which command is it ??
DanF
The same command listed by KasMcc, DSPUSRPRF. Press F4 to prompt then F9 for more parms.
Looks just like DSPUSRPRF to me.
Tom
I tested the DSPUSRPRF:
SBMJOB CMD(DSPUSRPRF USRPRF(userid) TYPE(*OBJOWN) OUTPUT(*OUTFILE) OUTFILE(mylib/userid))Worked fine and solved a big part of the problem.
Remaining is the IFS. Since I need the proces of finding objects and files to execute as BATCH, I wonder if this can be solved by using some Qshell command (find, grep !! piped to file) initiated from a CL-pgm.
Any thoughts (and example code..) on using QSH-commands are most welcome.
DanF
Dan,
Did you come up with a solution to get the list of owned objects in the IFS ?
I would be interested in the solution.
Thanks,
Bill Poulin
I have a basic ILE CL example that only retrieves the counts from the two calls of the API. To access the individual owned objects, the lists would need to be looped through. That’s done the same way any user space list is processed, so almost any other code sample could mostly be copied.
I originally created the example when I wanted to see what the API put into the user space, but I didn’t need anything more from it. The actual code that I’ve used in production can’t be supplied unfortunately, since it’s not mine.
The example accepts a user profile as a parm. It calls the API twice for the two separate lists, extracts the counts from the lists and then dumps its variables. I can answer questions about extending the example.
pgm ( + &pUsrPrf + ) dcl &pUsrPrf *char 10 dcl &UsrPrf *char 10 dcl &UsrSpc *char 10 value( 'LOBJOWN ' ) dcl &qusrspc *char 20 dcl &ErrCod *char 4 dcl &hCont *char 20 dcl &us_hdr *char 150 /* Space header */ dcl &l_hdr *char 34 /* List header */ /* Loop checking... */ dcl &LoopChk *dec 11 value( 0 ) /* Total objects... */ dcl &tObjOwn *dec 11 value( 0 ) dcl &tObjOwn2 *dec 11 value( 0 ) /* General fields for RUSGENHDR... */ dcl &nbrlste *int dcl &ists *char 1 dcl &offshdr *int chgvar &UsrPrf &pUsrPrf chgvar &hCont ' ' chgvar &qusrspc ( &UsrSpc *cat 'QTEMP' ) call QUSCRTUS ( + &qusrspc + 'TMPLST ' + x'00001000' + X'00' + '*ALL ' + 'Temp list obj owned ' + '*YES ' + x'0000000000000000' + ) QFS_obj: dountil ( &ists *ne 'P' ) call QSYLOBJA ( + &qusrspc + 'OBJA0100' + &UsrPrf + '*ALL ' + '*OBJOWN ' + &hCont + x'0000000000000000' + ) /* Retrieve the initialization data... */ call QUSRTVUS ( + &qusrspc + x'00000001' + x'00000096' + &us_hdr + ) chgvar &nbrlste %bin( &us_hdr 133 4 ) chgvar &ists %sst( &us_hdr 104 1 ) chgvar &offshdr %bin( &us_hdr 117 4 ) chgvar &offshdr ( &offshdr + 1 ) call QUSRTVUS ( + &qusrspc + &offshdr + x'00000022' + &l_hdr + ) chgvar &hCont %sst( &l_hdr 11 20 ) dmpclpgm if ( &nbrlste *eq 0 ) do sndpgmmsg msgid( CPF9898 ) msgf( QCPFMSG ) + msgdta( 'No objects listed' ) leave enddo /* Add this count to our total... */ chgvar &tObjOwn ( &tObjOwn + &nbrlste ) chgvar &LoopChk ( &LoopChk + 1 ) enddo chgvar &hCont ' ' IFS_obj: dountil ( &ists *ne 'P' ) call QSYLOBJA ( + &qusrspc + 'OBJA0110' + &UsrPrf + '*ALL ' + '*OBJOWN ' + &hCont + x'0000000000000000' + ) /* Retrieve the initialization data... */ call QUSRTVUS ( + &qusrspc + x'00000001' + x'00000096' + &us_hdr + ) chgvar &nbrlste %bin( &us_hdr 133 4 ) chgvar &ists %sst( &us_hdr 104 1 ) if ( &nbrlste *eq 0 ) do sndpgmmsg msgid( CPF9898 ) msgf( QCPFMSG ) + msgdta( 'No IFS objects listed' ) leave enddo /* Add this count to our total... */ chgvar &tObjOwn2 ( &tObjOwn2 + &nbrlste ) chgvar &LoopChk ( &LoopChk + 1 ) enddo Clean_up: dltusrspc QTEMP/&UsrSpc dmpclpgm return endpgmIt should compile and run on any V5R3 or later system.
Tom
BTW, as usual, pay attention to the quote marks. Many of them need to be transformed after this editor is done with them.
Tom
After a lot of searching, reading and experimenting, I believe that I am now very close to a solution. The essence of it is this:
I first created a PF to contain found ‘objects’ (filename MYFILE). then use qshell’s ‘find’ , and the result of this is piped to myfile.mbr.
CRTPF QRPLOBJ/MYFILE RCDLEN(200) SBMJOB CMD(STRQSH CMD('find / -type f -user userid > /qsys.lib/qrplobj.lib/myfile.file/myfile.mbr'))This seems to satisfy my need for a batch-processed solution, BUT……
my ‘small-scale’ test-results does not always compare to the result of the interactive WRKOBJOWN command., and that puzzles me.
For one test-user the result showed both elements from IFS and objects rom libraries presented as ‘qsys.lib/mylib.lib….’. For another test-user I only got the elemnts from IFS, and NOT this users owned objects in libraries.
I wonder if the cause for this is related to some security issue..
I currently try to work out sample tests to understand this behaviour.
Any thoughts on this is most velcome.
DanF
I don’t think you can rely on -type f to help. Actually, I’d expect that no type can give you what you’re trying for. You might need to try not specifying any type and then excluding everything you don’t want when you process the outfile.
Remember, a database file is an example of something that doesn’t match -type f, although each member will. Source files tend to give a lot of “files”.
Tom
Also, when using “/” as the starting directory, be careful with /QNTC and possibly others.
Tom
Tom, you are right
The -type f shall not be included.
My current solution is therefore this:
STRQSH CMD('find / -user userid > /qsys.lib/mylib.lib/myfile.file/myfile.mbr')I would like to include an option to omit , so fx /QNTC was not searched. I do not yet know if this can be acomplished…
This IBM manual on Qshell (page 62)
http://publib.boulder.ibm.com/iseries/v5r1/ic2924/info/rzahz/rzahz.pdf
describes the options for the find command, and I am especially looking into the [expression] part to solve my requirementfor omissions. Comments on this are welcome.
DanF
Under Qshell find Operators is this statement — “The primaries may be combined using the following operators.”
I haven’t tried it, but I’d look into the !expression operator, possibly combined with the expression -and expression. You might try “-user uname -and !-path /QNTC/*” or some more involved construct. I’m not sure what Qshell find will need to process everything in i5/OS terms rather than Unix terms.
The API will work better though. It’s really not too bad to extend the example.
Tom
Try this:
DSPOBJD OBJ(targetlib/*ALL) OBJTYPE(*ALL)
OUTPUT(*OUTFILE) OUTFILE(userlib/outfile)
Then query outfile:
SELECT *
FROM userlib/outfile
WHERE ODCRTU = ‘userid’