0% found this document useful (0 votes)
74 views

User Creation Script

The document contains PL/SQL code for creating a user with specific responsibilities and updating a user's password. It includes a cursor to fetch responsibilities for a 'System Administrator' and 'Application Developer', and handles exceptions during user creation and password updates. Additionally, it retrieves and decrypts user passwords from the database for specified usernames.

Uploaded by

Srikkanth Mani
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

User Creation Script

The document contains PL/SQL code for creating a user with specific responsibilities and updating a user's password. It includes a cursor to fetch responsibilities for a 'System Administrator' and 'Application Developer', and handles exceptions during user creation and password updates. Additionally, it retrieves and decrypts user passwords from the database for specified usernames.

Uploaded by

Srikkanth Mani
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

DECLARE

v_user_name VARCHAR2(30) := 'SRIKKAMTM'; -- User Name


v_password VARCHAR2(30) := 'Welcome123'; -- Password
-- List of responsibilities to be added automatically
CURSOR cur_get_responsibilities IS
SELECT
resp.responsibility_key,
resp.responsibility_name,
app.application_short_name
FROM
fnd_responsibility_vl resp,
fnd_application app
WHERE
resp.application_id = app.application_id
AND resp.responsibility_name IN ( 'System Administrator', 'Application
Developer' );

BEGIN
fnd_user_pkg.createuser(
x_user_name => upper(v_user_name),
x_owner => NULL,
x_unencrypted_password => v_password,
x_session_number => userenv(
'sessionid'
),
x_start_date => sysdate,
x_end_date => NULL
);

dbms_output.put_line('User '
|| v_user_name
|| ' created !!!!!');
FOR c_get_resp IN cur_get_responsibilities LOOP
fnd_user_pkg.addresp(
username => v_user_name,
resp_app => c_get_resp.application_short_name,
resp_key => c_get_resp.responsibility_key,
security_group => 'STANDARD',
description => NULL,
start_date => sysdate,
end_date => NULL
);

dbms_output.put_line('Responsibility '
|| c_get_resp.responsibility_name
|| ' added !!!!!!');
END LOOP;

COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Exception : '
|| substr(
sqlerrm,
1,
500
));
ROLLBACK;
END;
---------

Update Password

SET serveroutput ON;


DECLARE
v_user_name VARCHAR2(30):= UPPER('SYSADMIN');
v_new_password VARCHAR2(30):= 'welcome1';
v_status BOOLEAN;
BEGIN
v_status := fnd_user_pkg.ChangePassword ( username => v_user_name,
newpassword => v_new_password
);
IF v_status THEN
dbms_output.put_line ('The password reset successfully for the User:'||
v_user_name);
COMMIT;
ELSE
DBMS_OUTPUT.put_line ('Unable to reset password due to'||SQLCODE||' '||
SUBSTR(SQLERRM, 1, 100));
ROLLBACK;
END IF;
END;

------------

SELECT usr.user_name,usr.user_id,usr.description,
get_pwd.decrypt
((SELECT (SELECT get_pwd.decrypt
(fnd_web_sec.get_guest_username_pwd,
usertable.encrypted_foundation_password
)
FROM DUAL) AS apps_password
FROM fnd_user usertable
WHERE usertable.user_name =
(SELECT SUBSTR
(fnd_web_sec.get_guest_username_pwd,
1,
INSTR
(fnd_web_sec.get_guest_username_pwd,
'/'
)
- 1
)
FROM DUAL)),
usr.encrypted_user_password
) PASSWORD
FROM fnd_user usr
WHERE usr.user_name IN ('JOHMCCOR'/Jurgen@01) NATFLUTE/5678asdfghj@;

You might also like