Axon.ivy 7.0 - the Digital Business Platform - is out now...

I need some insights in the role system of Ivy. I currently check whether a user does have a role by checking whether the current user does have a role with the ID of that role I am interested in. One problem is that I have to hard code the ID's, another problem that the ID's are hard to retrieve and they are different on Designer and Server. Is there a more simple way to find out whether a specific user does have a specific role?

asked 06.08.2009 at 07:02

Benedict%20Groppe's gravatar image

Benedict Groppe
accept rate: 50%

You can use the PublicAPI to do so:


IRole myRole = ivy.request.getApplication().getSecurityContext().findRole("My Role");
IUser myUser = ivy.request.getApplication().getSecurityContext().findUser("My User");

boolean myUserHasMyRole = myUser.getUserToken().hasRole(myRole, false);

If you want to check for the user that is currently logged in, it is even more simple:


IRole myRole = ivy.request.getApplication().getSecurityContext().findRole("My Role");
boolean sessionUserHasMyRole = ivy.session.hasRole(myRole, false);

answered 10.08.2009 at 05:14

Christian%20Strebel's gravatar image

Christian St... ♦
accept rate: 88%

If you want to use this as a BackingBean it has a slightly different syntax - maybe this helps someone...

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import ch.ivyteam.ivy.environment.Ivy;

@ManagedBean(name = "roleCheckerBean")

public class RoleCheckerBean {
    public Boolean isUserSalesPerson() {

        IRole sales = Ivy.request().getApplication().getSecurityContext().findRole("sales");
        boolean sessionUserHasSalesRole = Ivy.session().hasRole(sales, false);

        return sessionUserHasSalesRole;

answered 10.04.2014 at 12:38

Nikel%20Weis's gravatar image

Nikel Weis
accept rate: 60%

Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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



Asked: 06.08.2009 at 07:02

Seen: 2,764 times

Last updated: 10.04.2014 at 12:38