• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 576
  • Last Modified:

Delete user profile automatically

Users on our system are spread around the world, people are terminated or quit without us knowing about it. We have a policy to delete any user profiles with no activity for 6 months.

Is it possible to do this with in a CL program or something? I want to automate the process.
0
roosterup
Asked:
roosterup
  • 4
  • 2
1 Solution
 
theo kouwenhovenCommented:
Hi roosterup,

We have did it already some time ago, but I'm not alowed to give you the source (company policy?).
But it works this way:
Create a CL-Program that will look like this:

Create a file with:
DSPUSRPRF USRPRF(*ALL)
          TYPE(*BASIC)
          OUTPUT(*OUTFILE)
          OUTFILE(library/file)
          OUTMBR(*FIRST *REPLACE)

use RCVF to read the records.
use the field UPPSOD to select the last logon date.
(exclude the standard users as QSECOFR QUSER etc. and also the users that are used for other jobs as FTPUSR etc.)

The selected user can be removed with:
DLTUSRPRF USRPRF(USER)          
          OWNOBJOPT(*CHGOWN new-owner)

The new owner can be a special created owner for this purpose or a standard user as QUSER.

Beware that you don't remove 'group profiles that are still in use'

Good lock.
0
 
samic400Commented:
murphey2 has the idea.

I'd be glad to put together some quick source code if you need it.

put this program in the IBM job schedule (or other job scheduler - Robot) and have it run automatically each month.
0
 
roosterupAuthor Commented:
samic400

that would be kewl, must increase points for that.
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
theo kouwenhovenCommented:
(additional information)

Beware: new userid's have a blank date, in that case you can use the field UPPWCD or even better!!!
Use in that case the creation date from the USRPRF-object

 RTVOBJD OBJ(userid)
         OBJTYPE(*USRPRF)
         CRTDATE(&DATE)    

(and don't forget to calculate the century fields)

UPPSOC for the Sign-on date
  and
UPPWCC for the password change date.

The creation date of the object is including the century (and time) in format CYYMMDDHHMMSS.

Regards Murphey
0
 
theo kouwenhovenCommented:
(addition 2)

To make no exceptions (makes the programming a lot easyer)

you can always retrieve the object description and use the last-used date to decide if the userprofile has to be deleted.
In that case use:
                         
RTVOBJD OBJ(userid)
        OBJTYPE(*USRPRF)
        CRTDATE(&CRTDAT)
        USEDATE(&USEDAT)

format:
(CRTDATE CYYMMDDHHMMSS)
(USEDATE CYYMMDD)
0
 
samic400Commented:
       pgm
        dcl &diff *dec (3 0)
        dclf file(lib/file)

        dspusrprf usrprf(*all) output(*outfile)   outfile (lib/file)

 read:  rcvf
        monmsg cpf0864  exec(goto end)
       
     /* you'll need code here to:   */
     /*   1 - weed out profile you wish to exclude - */
     /*       mostly all start with Q                */
     /*   2 - code to check for UPPSOD date being blank */
     /*       which means it hasn't been used - murphey2*/
     /*       had right idea about RTVOBJD cmd          */
     /*   3 - if date found, I'd convert to some sort of*/
     /*       julian date to see if not used in over 6  */
     /*       many ways to do this                   */

     if (&diff *gt 180) then(do)
     dltusrprf  usrprf(&UPUPRF) ownobjopt(*chgown quser)
     monmsg cpf0000 exec(do)  /* in case cannot do it */
     /* may want to send a message to someone with */
     /* reason why cannot delete - rcvmsg to get the */
     /* details is the way I'd do it                */
     enddo

     enddo

     goto read

 end: endpgm

I recommend you compile under QSECOFR and that the file in DCLF statement exists. That way not playing games with using OVRDBF with IBM files.                                                                      
0
 
theo kouwenhovenCommented:
Hey... my idea and no points ????
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now