Admin Alert Feedback: Quicker Ways to Change Library Object Ownership
January 25, 2006 Joe Hertvik
In a recent column, I stated that since the Change Object Owner command (CHGOBJOWN) did not have an *ALL function, there was no easy way to change object ownership for every single object in a library without writing a program to do the job. I was wrong in that assumption, and several readers wrote in to show me two different ways to reach that goal. So let’s look at what they shared and how it makes an administrator’s job easier.
The Challenge Is Met. . . Twice!
As laid out last time, the challenge was to find a way to quickly change the object ownership on every single object in a library in order to meet the needs of a third-party software package. I solved that need by writing a CL program that used IBM’s Display Object Description command (DSPOBJD) to create a file of all the objects in my target library, which the program was able to read and use the CHGOBJOWN command to change object ownership for each object in that library.
While the program wasn’t difficult to write (it only contained 12 lines of CL code), a prudent administrator never develops his own solution unless it is better than the solution that IBM provides. Several readers reminded me of this, and submitted two alternative solutions–one short and one long–that solve the problem in a more elegant fashion than I provided. (You live, you learn.) Here’s what they came up with.
CHGOWN: The Short Road to Object Ownership Changes
A number of readers alerted me to this solution, including Uno Ekberg, Vern Hamberg, K. Stoner, R. Vanhelvoirt and one reader who simply identified himself as Rob. These readers all reminded me that while CHGOBJOWN does not contain an *ALL function, the Change Owner command (CHGOWN) command does. But the kicker is that it is not obvious that you can use CHGOWN to affect all objects in a DB2 UDB library unless you are also familiar with the notation in OS/400’s Integrated File System (IFS). Let me explain.
CHGOWN is usually used to change ownership for stream file data objects that reside in several places in the IFS, including:
Stream file data is usually stored in standard PC-based or Unix-based formats, where the file name is defined in terms of its folder path name followed by its file name. So a file called joe.txt residing in the ‘/home/joe’ folder under the IFS root (/) directory would be designated by the following IFS notation:
To change the ownership of that file, then, I could run the following CHGOWN command.
CHGOWN OBJ(‘/home/joe/joe.txt’) NEWOWN(new_owner) RVKOLDAUT(*YES)
And CHGOWN changes the object ownership for my file to the user ID specified in the New owner parameter (NEWOWN). By default, this command also revokes all authority to the object for the old owner through the Revoke Current Authority parameter (RVKOLDAUT), which is usually set to *YES.
You can also use the CHGOWN command to change object ownership for native DB2 UDB objects, because they also reside in the AS/400 IFS under the qsys.lib file system. Like IFS stream file data, DB2 UDB object location can also be specified in IFS notation. To locate a file called JOE in the ITJUNGLE library on an i5 partition, for example, you would use the following IFS notation:
Knowing this, it’s easy to use CHGOWN to change ownership for my DB2 UDB object. I simply execute the CHGOWN command like this:
CHGOWN OBJ(‘/qsys.lib/itjungle.lib/joe.file’) + NEWOWN(new_owner)RVKOLDAUT(*YES)
For some rules and information about designating DB2 UDB objects in IFS notation, see the IBM’s iSeries Information Center Integrated File System Introduction to Path Name Rules for CL Commands and Displays.
To change the owner for all objects in the ITJUNGLE library, I can then modify this command with a wildcard designation of ‘*.*’ to designate all objects in that library, similar to how I would access all objects in a PC folder. To do this, I would run the command like this:
CHGOWN OBJ(‘/qsys.lib/itjungle.lib/*.*’) + NEWOWN(new_owner)RVKOLDAUT(*YES)
And with one command, I have changed ownership for each object in an entire library. This is the shortest way my readers have told me about so far to perform this task.
PDM: The Second Fastest Way to Object Ownership Changes
The second new solution to this problem was submitted to me by readers Bob Spicer and Richard Comstock. This technique harnesses the power of PDM to change the owner on multiple library objects at one time. This is a multi-step process but, once it’s set up, you can use it whenever you want, directly from your PDM screen. Here’s how this technique works.
1. Enter PDM from the green screen by typing in the Start PDM command (STRPDM).
2. On the AS/400 Programming Development Manager (PDM) screen that appears, select option 2, Work with objects.
3. The Specify Objects to Work With screen will appears. Enter the name of the library you want to change object ownership for in the Library parameter. Also be sure to specify *ALL in the Name, Type, and Attribute parameters on this screen, in order to be sure that PDM displays all the objects in the library you want to change. Press ENTER and the program will display all objects in that library on the Work with Objects Using PDM screen.
4. On the Work with Objects Using PDM screen, select F16 to enter the Work with User-Defined Options screen. On this screen, you can add extra one- to two-digit options for launching commands directly from entries on the Work with Objects Using PDM screen. Your new option to change object ownership will be available in addition to all the familiar PDM options that IBM already supplies, such as 2=Change, 5=Display, WS=Work with Submitted Jobs, SP=Work with All Spooled Files, etc.
5. On the Work with User-Defined Options screen, press F6 to create a new option for changing an object’s owner. This brings up the Create User-Defined Option screen To enter an option that uses the CHGOBJOWN command to change the object owner for the current entry on the screen, you could create a ‘CP’ option with the following command line:
CHGOBJOWN OBJ(&L/&N) OBJTYPE(&T) NEWOWN(new_owner)
The parameters &L, &N, and &T represent the library name, object name, and object type of the PDM object entry that you will be launching the ‘CP’ option from. Save the command and return to the Work with Objects Using PDM screen.
By adding this new user-defined option, every time you type ‘CP’ in front of an object entry on the Work with Objects Using PDM screen, PDM will use the CHGOBJOWN command to change that object’s owner to the new_owner value defined in your ‘CP’ user-defined option.
6. To change the owner for all the objects in the library, place a ‘CP’ in front of the first object in the Work with Objects Using PDM list and then press the F13 key (Repeat), which will duplicate your ‘CP’ entry for every object in that library list. Once you see ‘CP’ in front of every object in the list, press the ENTER key and PDM will change the objects’ owner for all objects on the screen.
This technique works but there are a few drawbacks. First, the new_owner is hard-coded in the ‘CP’ User-Defined entry, which means that if you want to change the new owner’s name, then you have to open and re-edit the entry. The second drawback is that PDM usage is starting to go down in the i5/OS and OS/400 world. With IBM’s encouragement, many programmers are switching to WebSphere Development Studio, which is a graphical interface that may not execute this option. But this technique will work in a pinch if you can not use the CHGOWN command or the CL program technique I wrote up in my last column.
So Which Is the Best Technique to Use?
For my money, the CHGOWN command is the best technique to use for changing the owner for every single object in a library. It’s easy to use and it requires no coding or modification when a parameter changes. This does not mean that the other two techniques are not without merit. The PDM technique shows us an easy way to add new user-defined options to the PDM environment, while the CL programming technique shown in my other column can easily be modified to perform any number of operations on all objects in a library.
IBM’s iSeries Information Center, Integrated File System Introduction to Path Name Rules for CL Commands and Displays