This discussion is archived
6 Replies Latest reply: Feb 25, 2013 11:13 PM by 978518 RSS

How to chage password of user's webLogic  programmatically

Habib.Eslami Explorer
Currently Being Moderated
Hi
My English isn't very good.
I use jdeveloper 11.1.1.3.0

I created a User Id and Password in Application -> Secure -> Users in jazn-data.xml. I know it isn't a common way but now I should use it.
I need a way that each user can change his/her password from a form I make for him/her.How can I do it?

also I want to know that is it possible to create user/pass programmatically?

Habib

Edited by: Habib Eslami on Feb 23, 2013 9:54 PM

Edited by: Habib Eslami on Feb 25, 2013 4:18 AM
  • 1. Re: change password in jazn-data.xml programmatically
    978518 Newbie
    Currently Being Moderated
    Hi Habbi ,

    You can create a user by using below code,

    And also you can change the password for specific user by using change password method. Every thing possible with ADF :)

    Note : before proceding with this you need to create group named 'member' (You can specify any thing) in your weblogic admin

    public boolean createUser(String username, String password) {
    try
    {
    JpsContextFactory jps = JpsContextFactory.getContextFactory();
    JpsContext jpsContext = jps.getContext();
    IdentityStoreService storeService =
    jpsContext.getServiceInstance(IdentityStoreService.class);
    IdentityStore is = storeService.getIdmStore();
    UserManager mn = is.getUserManager();
    RoleManager rm = is.getRoleManager();
    Principal p =
    mn.createUser(username, password.toCharArray()).getPrincipal();
    Role r = is.searchRole(is.SEARCH_BY_NAME, "member");

    rm.grantRole(r, p);
    result="success";
    return true;
    }

    catch (Exception e) {
    System.out.println(e.getMessage());
    if(e.getMessage().equalsIgnoreCase("User "+userName.getValue().toString()+"already exists"))
    {
    // errorMessageOT.setValue("User already exists!");


    }
    else
    {


    }
    e.printStackTrace();
    result="error";
    return false;
    }
    }
  • 2. Re: change password in jazn-data.xml programmatically
    Habib.Eslami Explorer
    Currently Being Moderated
    Thanks. It was really useful.

    Could you please explain more about how to change password?
    Also does it exist any articles about create user and change password?

    Habib

    Edited by: Habib Eslami on Feb 25, 2013 3:05 AM
  • 3. Re: change password in jazn-data.xml programmatically
    EsmaielSoroor Newbie
    Currently Being Moderated
    Hi Habib :
    PLease this

    http://soadev.blogspot.com/2010/04/sqlauthenticatoradapter-weblogic-mbeans.html
  • 4. Re: change password in jazn-data.xml programmatically
    978518 Newbie
    Currently Being Moderated
    Hi Habib,

    For documentation you can read the developer guide. You ll get full info :D

    And the fallow the below code for change password i tried for you with an example, hope it helps you...

    JpsContextFactory jps = JpsContextFactory.getContextFactory();
    JpsContext jpsContext=jps.getContext();
    IdentityStoreService storeService = jpsContext.getServiceInstance(IdentityStoreService.class);
    IdentityStore is = storeService.getIdmStore();
    UserManager mn = is.getUserManager();
    boolean flag=mn.isModifyUserSupported();
    //String userName="Pavan@gmail.com";
    User user = (User)is.searchUser(emailId);
    System.out.println("User details:"+user.getUserProfile().getUserName());
    UserProfile userprofile =user.getUserProfile();
    char[] oldp=oldPassword.getValue().toString().toCharArray();
    char[] newp=newPassword.getValue().toString().toCharArray();
    if(newPassword.getValue().toString().equals(confirmPassword.getValue().toString()))
    {
    if(!newPassword.getValue().toString().equals(oldPassword.getValue().toString()))
    {
    userprofile.setPassword(oldp,newp);

    Regards,
    PY
  • 5. Re: change password in jazn-data.xml programmatically
    Habib.Eslami Explorer
    Currently Being Moderated
    Hi
    Thanks very much.
    I need documents about your codes give me to completely understand codes.
    Can I find anything in developer guide?

    Habib
  • 6. Re: change password in jazn-data.xml programmatically
    978518 Newbie
    Currently Being Moderated
    By document,can not understand the code(Instead fallow API's provided by oracle :))....

    Fallow developer guide you will find solution based on your requirement (or at least hints :D)


    Thanks
    PY

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points