cancel
Showing results for 
Search instead for 
Did you mean: 

Adding users to role programmatically

Former Member
0 Kudos

Hi

I have a written a Portal Service which will accept the Portal user and Portal role. I am trying to adding Portal Role to the user programmatically using ume apis so that when the user logs in, he can see the Worksets related to this Portal Role.

I am passing the Portal user id and Portal role, But this is not working it is giving me an exception Portal Role is invalid, but I have this role in Portal.

What could be the problem?

Regards

Senthil

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Senthil,

Try this code. It worked well for me.

IUser iuser=UMFactory.getUserFactory().getUserByUniqueName("xxx");//give user id here
IRole irole=UMFactory.getRoleFactory().getRoleByUniqueName("yyy");//give role name here

String useruid=iuser.getUniqueID();
String roleuid=irole.getUniqueID();

UMFactory.getRoleFactory().addUserToRole(useruid,roleuid);

Hope this solves your problem.

Ranjith

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ranjith

Thanks for the code. It worked.

This was the line which was missing in the code.

IRole irole=UMFactory.getRoleFactory().getRoleByUniqueName

Regards

Senthil