Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
Mass-Change of Object Owner
has no ratings.
Published: 05 Nov 2011
Revised: 23 Jan 2013 - 4111 days ago
Last viewed on: 25 Apr 2024 (10092 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Mass-Change of Object Owner Published by: Bob Cozzi on 05 Nov 2011 view comments(10)

We have a situation where we have a USER that will no longer be signing onto the system. This often happens when Employees leave the company.

This User Profile owns all of the objects that they created on the system over the many years. So there are thousands of them in at least a dozen different libraries.

I'm wondering how shops handle this kind of thing; when I user leaves and their user profile owns objects? My solution was to write a RNMOBJOWN (Rename Object Owner) CL command that changes the owner of every object owned by User X to User Y.

SOLUTION: There is a DLTUSRPRF parameter that allows a mass-change of ownership. Specify the "Owner's Objects Option" and you can change the owner while deleting. Here's something I've been using but forgot about:

DLTUSRPRF  USRPRF(&OLDOWN) OWNOBJOPT(*CHGOWN &NEWOWN) 

The only thing about this choice, is that it requires that you are deleting the old profile. I suppose that's fine, but in our case, they've embedded it into things like FTP scripts with customers/vendors so we can't really delete it as yet.

I also couldn't believe that after 30 years CHGOBJOWN is still NOT generic; thankfully the IFS-related CHGOWN command does support generic names and I've used it for a long time instead of CHGOBJOWN, but I used CHGOBJOWN under the covers for RNMOBJOWN.

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: Ringer
Premium member *
Comment on: Mass-Change of Object Owner
Posted: 12 years 5 months 22 days 1 hours 6 minutes ago
Edited: Sat, 05 Nov, 2011 at 15:29:32 (4556 days ago)

Perhaps a CHGOWN with an /QSYS.LIB/ type IFS path and SUBTREE(*ALL) with wildcard *.* would work.

Chris Ringer

PS: Oops, I see that you *did* use CHGOWN.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Mass-Change of Object Owner
Posted: 12 years 5 months 21 days 19 hours 14 minutes ago

CHGOWN doesn't allow you to tell it to change only the objects that are currently owned by User X. It does support generic, however, as you implied.

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Mass-Change of Object Owner
Posted: 12 years 5 months 20 days 7 hours 3 minutes ago

We avoid this by having all user profiles with OWNER(*GRPPRF).


You could easily write a program, though, and it's fairly trivial. DSPUSRPRF <x> *OBJOWN to outfile would work, or there's an API, List Objects User Is Authorized to, Owns, or Is Primary Group of (QSYLOBJA) API.

The one thing you need to watch out for is programs that use adopted authority. For *PGM objects need to retrieve program attributes, and skip if USRPRF(*OWNER). Send a message or write to a report or something, so that you can follow up later.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Mass-Change of Object Owner
Posted: 12 years 5 months 20 days 6 hours 17 minutes ago

Dale,

The DSPUSRPRF OUTFILE... suggestion is great--I didn't realize they added outfile support to that command. I'm torn however, the DSPOBJD gives me more granular control over changing object ownership, whereas DSPUSRPRF is more for global change-own; effectively giving me the same results as DLTUSRPRF's OWNOBJOPT and PGPOPT parameters.

Perhaps for the migration is use DSPUSRPRF... and for a generic "Cozzi Utility" I use DSPOBJD instead.

Thanks!

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Mass-Change of Object Owner
Posted: 12 years 5 months 20 days 5 hours ago

I had written a CHGLIBOWN a long time ago, so it was DSPOBJD, but there's really not much in the loop except CHGOBJOWN and a few monitors. I tested for current owner equal to target owner, for performance, but that doesn't apply when you're starting from a specific user. I just remember getting burned on a program that had adopted authority; you need to look for that.

Posted by: Paulster
Premium member *
Sweden and The Netherlands
Comment on: Mass-Change of Object Owner
Posted: 12 years 5 months 19 days 11 hours 33 minutes ago

Bob,

Why don't you take the bigger step and change the owner for all objects to a group profile? You then make sure all newly created objects automatically get this group profile as owner (group profile parameter on user profile) and you can forget about who's leaving and who stays.

 

Regards,

Paulster

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Mass-Change of Object Owner
Posted: 12 years 5 months 19 days 9 hours 50 minutes ago

Wait, I missed something you said back there, Bob, "DSPUSRPRF is more for global change-own." Try DSPUSRPRF <x> *OBJOWN to outfile. You can't outfile all of the options on DSPUSRPRF, but *OBJOWN is allowed.

Posted by: svetlana0777
Premium member *
Comment on: Mass-Change of Object Owner
Posted: 12 years 30 days 13 hours ago

Hello guys,

 

if I don't understand something? I have V5R3 and V5R4M5 on my servers now but I don't have RNMOBJOWN command... Frown

 

Your advices to use DSPUSRPRF  *OBJOWN  *OUTFILE helped me tremendously even it does not show IFS objects... Do you have any ideas how to get a list of IFS-objects what the USRPRF own?

 

Thank you very much.

Svetlana

Posted by: Paulster
Premium member *
Sweden and The Netherlands
Comment on: Mass-Change of Object Owner
Posted: 12 years 30 days 11 hours 59 minutes ago

Hi S,

Nope, you're not missing anything. The RNMOBJOWN command was something new that Bob intended to write. So it is not on your server.

Google your other question and you get a bunch of workable examples. Something like RTVDSKINF might also be helpful. You may need to pick up on your QSHELL knowledge.

Regards,
Paulster

Posted by: svetlana0777
Premium member *
Comment on: Mass-Change of Object Owner
Posted: 12 years 29 days 10 hours 24 minutes ago

Thank you!

 

PS Yeah, when we talk about IFS, QSHELL rules. You are right I have to study it finally ;)