cancel
Showing results for 
Search instead for 
Did you mean: 

Assign a Role dynamically

Former Member
0 Kudos

Hi All,

I have and application in webdynpro and I need include a java code to Add a role to the current user acording to an action in my program.

I would like to know if is possible add and delete a role from the application.

Thanks in advance,

Alexis

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can assign portal roles to user using the UMFactory. Please do check the same.

It is possible to assign the role to user through code.

UMFactory rf = UMFactory.getRoleFactory();

rf.addUserToRole("petermueller", "role1");

But the above code is from a portal perspective do check with regard to webdynpro.

Former Member
0 Kudos

I hope this is what you require.

IUser user=UMFactory.getUserFactory().getUserByUniqueName("<userId>");

String name= user.getUniqueID();

IRoleFactory fact=UMFactory.getRoleFactory();

IRole role=fact.getRoleByUniqueName("super_admin_role");

String roleId=role.getUniqueID();

fact.addUserToRole(name,roleId);

Please let me know.

Former Member
0 Kudos

Hello Noufal!

this sounds great, but where has this code to be executed?

I have a similar problem; New users from a R/3-backend are replicated to the portal's user database.

According to R/3-roles I have to assign portal roles to these new portal users automatically.

Where do I have to implement appropriate coding?

thanks

Andreas

Former Member
0 Kudos

Hello Adreas,

You can assign roles automatically executing a Webdynpro application in portal, it should works fine.

Regards

Alexis

Answers (1)

Answers (1)

Former Member
0 Kudos

Did you end up writing a custom login module to assign the portal roles dynamically according to what R/3 roles they had?