Hi I want to assign a role to a user permanently in my software. And i need to this programmatically. Can anyone help me out? I tried the addRole function in IUsers but this is just temporary i think. Best regards Florian

asked 30.06.2016 at 15:33

Florian%20Hitz's gravatar image

Florian Hitz
(suspended)
accept rate: 0%


Hi

You can asign a role to a user by executing the following script:

import ch.ivyteam.ivy.security.ISecurityContext;
import ch.ivyteam.ivy.security.IUser;
import ch.ivyteam.ivy.security.IRole;

ISecurityContext securityContext = ivy.wf.getApplication().getSecurityContext();
IUser user = securityContext.findUser("myUser");
IRole role = securityContext.findRole("myRole");
user.addRole(role);

This will assign the role permanantely to the user.

Note that the role assignment is not forwarded automatically to sessions of the user. The user has to log out and login again so that he can act as the role.

link

answered 01.07.2016 at 10:46

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.9k202857
accept rate: 74%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×40
×35

Asked: 30.06.2016 at 15:33

Seen: 2,329 times

Last updated: 01.07.2016 at 10:46