cancel
Showing results for 
Search instead for 
Did you mean: 

How to check whether portal user exists or not using UM API.

Former Member
0 Kudos

Hi Experts,

Let us say i need to create an user account "PortalUser",i know how to create an user,setting first name,lastname,password for that.

but here before creating the portal user, i need to check whether that user exists or not.If user already exists ,then i need to skip the below for creating the user.

IUserFactory userFact = UMFactory.getUserFactory();

IGroupFactory groupFact = UMFactory.getGroupFactory();

IRoleFactory roleFact = UMFactory.getRoleFactory();

IUser tuser = userFact.getUserByLogonID("PortalUser");

{

IUserMaint newUser = userFact.newUser("PortalUser");

newUser.setFirstName("PortalUser");

newUser.setLastName("Test");

newUser.setEmail("PortalUser.Testatgmaildotcom");

//Locale PortalLanguage = new Locale(Lang.toLowerCase(), "");

Locale PortalLang=new Locale("en");

newUser.setLocale(PortalLang);

newUser.save();

newUser.commit();

IUserAccount userAcc = UMFactory.getUserAccountFactory().newUserAccount("PortalUser", newUser.getUniqueID());

userAcc.setPassword("test1test$");

userAcc.save();

userAcc.commit();

}

Thanks in advance.

Thanks

Sony.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try this code,

IUserFactory factory = UMFactory.getUserFactory();

IUser user = factory.getUserByLogonID(userId);

lastName = user.getLastName();

firstName = user.getFirstName();

refer this pdf,its very helpful

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/events/webinars-nw...

Regards,

Sunaina Reddy T

Former Member
0 Kudos

Hi Ambica,

Check out the following thread

By this code you can retrieve the user and check it against the user you are trying to create.

If the user already exists skip the step of user creation

Former Member
0 Kudos

use the .getUser() method of IUserFactory to fet the user and compare it with the user you are trying to create.

You can also use isUserCreationPossible() returns true if an IUser can be created, otherwise false.

Former Member
0 Kudos

Hi Sharma,

Thanks for the quick reply.

Can you please eloborate the answer.

Thanks in Advace.

Sony