Skip to Content
avatar image
Former Member

Create portal user using UME api's

Is there an example whicg explains how to create a portal user using the UME api's ? We would like to develop a Web Dynpro app for adding users in batches. See a bunch api's in the NWDS documentation which deals with user account maintanence, profile look-up etc., but none for creating users. Please advise.

Thanks !

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Nov 14, 2005 at 08:07 PM

    Hi,

    see /thread/47272 [original link is broken]

    Hope it helps

    Detlev

    PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 15, 2005 at 09:48 AM

    Hi Srikanth,

    Before using this code add the security.api jar file to your project's buildpath. For that, in your NWDS, navigate to Your_project->properties->Java Build path->Libraries->Add variable->Click on Eclipse Home->extend->plugins->com.sap.security->lib->com.sap.security.api.jar.

    <b>creating a new user, user account & assigning this user to a role</b>

    // creating a user

    IUserFactory userfact = UMFactory.getUserFactory();

    IUserMaint userMaint = userfact.newUser("TestUser");

    userMaint.setDisplayName("My Name");

    userMaint.setFirstName("Test");

    userMaint.setLastName("User");

    userMaint.save();

    userMaint.commit();

    // assigning a role (in this case 'administrator') to the user

    IRole role = null;

    role=UMFactory.getRoleFactory().getRoleByUniqueName("Administrator");

    if(null!=role)

    {

    wdComponentAPI.getMessageManager().reportSuccess("Adding User::"userMaint.getName()" to role ::"+role.getDisplayName());

    UMFactory.getRoleFactory().addUserToRole(userMaint.getUniqueID(),role.getUniqueID());

    }

    // creating an account for the user

    IUserAccountFactory accountFact = UMFactory.getUserAccountFactory();

    IUserAccount account = accountFact.newUserAccount("MyLogonID",userMaint.getUniqueID());

    account.setPassword("password");

    account.save();

    account.commit();

    Now you will be able to login with user name 'MyLogonID' and password 'password'.

    Hope this helps,

    Best Regards,

    Nibu.

    Add comment
    10|10000 characters needed characters exceeded