cyc1111 发表于 2015-9-23 09:17:55

Oracle EBS 初始化用户密码

---修改密码,并且将限制用户下次登录的时候(第一次登录),强制要换一个新的口令:
---此过程可以完全模拟我们在标准用户的Form里面初始化用户的密码的动作!

---最后要说明的是,这个处理过程是通过研究标准创建用户的画面得出来的结果,所以,如果有需要,请放心使用!
SELECT last_logon_date,password_date,LAST_UPDATE_DATE,LAST_UPDATE_LOGIN
FROM FND_USER
WHERE USER_NAME = 'QWR01';

DECLARE
   P_USER_NAME FND_USER.USER_NAME%TYPE;
   P_INIT_PASSWORD VARCHAR2(30);---初始化密码,非加密的。
   ---
   l_change_flag VARCHAR2(10);
   l_reason varchar2(2000);
BEGIN
    ---输入参数(用户名和初始化的密码)
    P_USER_NAME := 'QWR01';
    P_INIT_PASSWORD := 'PWD123';
   
    ---------
    ---处理--
    L_change_FLAG := fnd_web_sec.change_password(P_USER_NAME,P_INIT_PASSWORD);


    IF L_change_FLAG = 'Y' THEN
      -- Bug 7016473 - During an administrative reset, set the last_logon_date to NULL
      -- instead of SYSDATE.last_logon_date should reflect the date the user last
      -- logged in successfully, not the date the user's password was reset.
      -- This does not regress the fix for bug 4690441 because in fnd_web_sec.disable_user
      -- if last_logon_date is NULL, the last_update_date will be used which is the same
      -- date of the sysadmin reset, so the effect is the same.
      --
      -- Reset password_date field to null to force password
      -- expiration the next time user logs on.
      --
      UPDATE FND_USER
      SET last_logon_date= NULL
         ,password_date = NULL
         --,LAST_UPDATE_DATE = SYSDATE
         --,LAST_UPDATE_LOGIN = FND_GLOBAL.LOGIN_ID
         WHERE USER_NAME = P_USER_NAME;
      
      COMMIT;
      ----
      DBMS_OUTPUT.PUT_LINE('成功初始化用户('||P_USER_NAME||')的密码为:'||P_INIT_PASSWORD);
    ELSE
      ---显示为什么不可以修改
      l_reason := fnd_message.get;
      fnd_message.set_name('FND', 'FND_CHANGE_PASSWORD_FAILED');
      fnd_message.set_token('USER_NAME', P_USER_NAME);
      fnd_message.set_token('REASON', l_reason);
      app_exception.raise_exception;
    END IF;
END;
页: [1]
查看完整版本: Oracle EBS 初始化用户密码