Thursday, 9 June 2011

API’s to Create User,Reset Password and Add Responsibility


API’s to Create User,Reset Password and Add Responsibility

I have created few queries using Oracle provided package:’FND_USER_PKG’. These queries might be very useful when you donot have the Oracle Apps front end access or you like to get in done through backend.
Using the below query, you can create a User in Oracle application.Just pass username, password and email id as parameters and it will create a user.
declare
v_user_name varchar2(30):=upper('&Enter_User_Name');
v_password varchar2(30):='&Enter_Password';
v_session_id integer := userenv('sessionid');
v_email varchar2(30):=upper('&Enter_Email_Id');
begin
  fnd_user_pkg.createuser (
  x_user_name => v_user_name,
  x_owner => null,
  x_unencrypted_password => v_password,
  x_session_number => v_session_id,
  x_start_date => sysdate,
  x_end_date => null,
  x_email_address => v_email
  );
  commit;
  DBMS_OUTPUT.put_line ('User:'||v_user_name||'Created Successfully');
EXCEPTION
when others then
  DBMS_OUTPUT.put_line ('Unable to create User due to'||SQLCODE||' '||SUBSTR(SQLERRM, 1, 100));
  ROLLBACK;
end;
May a times we forgot the apps password. Then you can use the below query to resent the password just in few seconds.

declare
v_user_name varchar2(30):=upper('&Enter_User_Name');
v_new_password varchar2(30):='&Enter_New_Password';
v_status boolean;
begin
 v_status:= fnd_user_pkg.ChangePassword (
    username => v_user_name,
    newpassword => v_new_password
  );
  if v_status =true 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;
Use the below query to add a responsibility to a user. The advantage here is that you donot require system administrator responsibility access to add a responsibility.


declare
v_user_name varchar2(30):=upper('&Enter_User_Name');
v_resp varchar2(30):='&Enter_Responsibility';
v_resp_key varchar2(30);
v_app_short_name varchar2(50);
begin
  select
    r.responsibility_key ,
    a.application_short_name
  into v_resp_key,v_app_short_name
  from fnd_responsibility_vl r,
    fnd_application_vl a
  where
    r.application_id =a.application_id
    and upper(r.responsibility_name) = upper(v_resp);

  fnd_user_pkg.AddResp (
  username => v_user_name,
  resp_app => v_app_short_name,
  resp_key => v_resp_key,
  security_group => 'STANDARD',
  description => null,
  start_date => sysdate,
  end_date => null
  );
  commit;
  DBMS_OUTPUT.put_line ('Responsibility:'||v_resp||' '||'is added to the User:'||v_user_name);
EXCEPTION
when others then
  DBMS_OUTPUT.put_line ('Unable to add the responsibility due to'||SQLCODE||' '||SUBSTR(SQLERRM, 1, 100));
  rollback;
end;



post signature

11 comments:

Anonymous said...

I leave a leave a гeѕρonse whеneѵer I
espeсіаlly еnjoy a article on
а website οr if Ι have something to contribute to
thе dіѕcussion. It іs a гeѕult of the paѕsion diѕplayed
in the artiсle І browsed. And on this аrticle
"API's to Create User,Reset Password and Add Responsibility".

I was excited enough to dгop a commеnt ;-) I actuallу do
have a few questions for you if you uѕually do not mіnd.
ӏs it only me or does it appear like some of the remаrks cоme across as if they are left by brain ԁead
people? :-P And, if you are writing at additionаl ρlacеs,
I'd like to keep up with everything new you have to post. Could you list the complete urls of your communal pages like your linkedin profile, Facebook page or twitter feed?

Also visit my web site luminess air

Anonymous said...

Very good information. Lucky me I discovered your blog by
chance (stumbleupon). I've book-marked it for later!

Also visit my site; Twitter Hack Download

Anonymous said...

You really make it seem so easy with your presentation but I find this matter to be actually
something that I think I would never understand. It seems too complex and extremely broad for me.

I am looking forward for your next post, I will try to get the hang of it!


my blog Minecraft Premium Account Hacks

Anonymous said...

Hello there! I know this is kinda off topic nevertheless I'd figured I'd ask.

Would you be interested in exchanging links or maybe guest writing a blog post or vice-versa?
My site addresses a lot of the same topics as yours
and I think we could greatly benefit from each other.

If you might be interested feel free to shoot
me an e-mail. I look forward to hearing from you! Superb blog by the way!


My web page - oph crack

Anonymous said...

Touche. Solid arguments. Keep up the amazing spirit.

My webpage; how to earn money with investment

Anonymous said...

Nice blog here! Also your site loads up very fast! What web host are you using?
Can I get your affiliate link to your host? I wish my site loaded
up as fast as yours lol

Also visit my blog post ... Garcinia Cambogia Extract

Anonymous said...

I think this is among the most vital info for me.
And i am glad reading your article. But should remark on some general things,
The website style is perfect, the articles is really excellent :
D. Good job, cheers

Feel free to surf to my page - How To Hack Twitter

Anonymous said...

Have you ever considered about adding a little bit more than just your articles?
I mean, what you say is fundamental and everything.
Nevertheless think of if you added some great graphics or video clips to give your posts more, "pop"!
Your content is excellent but with pics and videos, this site could definitely be one of the most beneficial in its field.
Great blog!

My website - hack A twitter

Anonymous said...

Hi, the whole thing is going perfectly here and ofcourse every one
is sharing data, that's actually excellent, keep up writing.

Visit my homepage: minecraft free

Anonymous said...

If some one needs to be updated with hottest technologies
therefore he must be pay a visit this web site and be
up to date everyday.

Feel free to visit my blog post ... How To Make Money In The Internet

Anonymous said...

I don't know whether it's just me or if perhaps everybody else encountering problems with your site.
It appears as though some of the written text on
your posts are running off the screen. Can someone else please
provide feedback and let me know if this is happening to them too?
This may be a problem with my browser because I've had this happen previously. Kudos

Feel free to surf to my website; crack password