SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Automatic lock off inactive users



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Security and Monitoring
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Jun 07, 2008 10:57 am    Post subject: Automatic lock off inactive users Reply with quote

Automatic lock off inactive users.
(Warning !! Do not use this report on a CUA Master Client)

Code:
*&---------------------------------------------------------------------*
*& Report  Z_LOCK_INACTIVE_USERS
*    Author : Morten Hjorth Nielsen
*    Webpage: http://www.mortenhjorthnielsen.com
*
*    Purpose: automatic lock of inactive user, not signed in during p_days
*
*    The report will not lock the users SAP*, DDIC and SAPCPIC
*
*    DO NOT USE THIS REPORT ON A CUA MASTER CLIENT !!!!
*
*    This report is meant for inspiration, before you use it in a productive
*    environment please Test and Adjust thoroughly
*&---------------------------------------------------------------------*

REPORT  z_lock_inactive_users.

TABLES: usr02.

PARAMETER:      p_days(3).                     "Number of inactive days

SELECT-OPTIONS: p_type FOR usr02-ustyp.

DATA: lv_date LIKE usr02-trdat,
      lv_user LIKE bapibname-bapibname,
      itab_usr02 LIKE usr02 OCCURS 0 WITH HEADER LINE,
      return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

lv_date = sy-datum - p_days.                    " Calculate date

REFRESH itab_usr02.

SELECT * FROM usr02 INTO itab_usr02             "Users that has been logged on
  WHERE trdat LE lv_date
    AND bname NOT IN ('SAP*' , 'DDIC' , sy-uname)
    AND uflag EQ 0
    AND ustyp IN p_type.
ENDSELECT.                                                  "usr02


SELECT * FROM usr02 APPENDING TABLE itab_usr02  "Users that hasn't been logged on
  WHERE trdat EQ '00000000'
    AND erdat LE lv_date
    AND bname NOT IN ('SAP*' , 'DDIC', 'SAPCPIC' , sy-uname)
    AND uflag EQ 0
    AND ustyp IN p_type.
*ENDSELECT.           "usr02


LOOP AT itab_usr02.
  CLEAR lv_user.
  REFRESH return.

  lv_user = itab_usr02-bname.

  CALL FUNCTION 'BAPI_USER_LOCK'                " Lock user
    EXPORTING
      username = lv_user
    TABLES
      return   = return.

  IF return-type =  'S'.
    WRITE: / lv_user, ' locked'.
  ENDIF.
ENDLOOP.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Security and Monitoring All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.