<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: PermissionDeniedException when calling iUser.getAllRoles()</title><link>https://answers.axonivy.com/questions/548/permissiondeniedexception-when-calling-iuser-getallroles</link><description>&lt;p&gt;My call to &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;aUser.getAllRoles();&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;throws the exception:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;PermissionDeniedException: Session 1 (cuongtruc.tran) is not allowed to call method public java.util.List ch.ivyteam.ivy.security.internal.User.getAllRoles().
   The session does not fulfill the permission rule SESSION (MATCHES THIS AND OWNS UserReadOwnRoles PERMISSION) OR OWNS UserReadRoles PERMISSION OR OWNS UserReadRoles@SYSTEM PERMISSION&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I even tried with grant admin permisson to that user but still throws the same exception.&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/548/permissiondeniedexception-when-calling-iuser-getallroles" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 04 Mar 2014 17:21:59 -0500</lastBuildDate><item><title>Comment by Reto Weiss on Raphael Bürgin's answer</title><link>https://answers.axonivy.com/questions/548/permissiondeniedexception-when-calling-iuser-getallroles#560</link><description>&lt;p&gt;The method getRoles() only returns the roles that are directly assigned to the user. Whereas the method getAllRoles() returns also the roles that the user inherits because of the hierarchy of the roles.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reto Weiss</dc:creator><pubDate>Tue, 04 Mar 2014 17:21:59 -0500</pubDate><guid>https://answers.axonivy.com/questions/548/permissiondeniedexception-when-calling-iuser-getallroles#560</guid></item><item><title>Comment by Tran Cuong Truc on Tho Tran's answer</title><link>https://answers.axonivy.com/questions/548/permissiondeniedexception-when-calling-iuser-getallroles#551</link><description>&lt;p&gt;This way is overtake the root permisson, it works thought but I'm worry about security. &lt;/p&gt;
&lt;p&gt;But anyway, it will be an alternative way if the method below doesn't work. :)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tran Cuong Truc</dc:creator><pubDate>Thu, 27 Feb 2014 03:21:29 -0500</pubDate><guid>https://answers.axonivy.com/questions/548/permissiondeniedexception-when-calling-iuser-getallroles#551</guid></item><item><title>Answer by Raphael Bürgin</title><link>https://answers.axonivy.com/questions/548/permissiondeniedexception-when-calling-iuser-getallroles/550</link><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You can execute your code with systemUserPermissions using a callable function.
In this Example I get a List of Roles of a User. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;List&amp;lt;IRole&amp;gt; roles = Ivy.session().getSecurityContext().executeAsSystemUser(new Callable&amp;lt;List&amp;lt;IRole&amp;gt;&amp;gt;(){
            public List&amp;lt;IRole&amp;gt; call() throws Exception {
                List&amp;lt;IRole&amp;gt; roles = iuser.getRoles();
                return roles;
            }

        });
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Raphael Bürgin</dc:creator><pubDate>Wed, 26 Feb 2014 15:42:13 -0500</pubDate><guid>https://answers.axonivy.com/questions/548/permissiondeniedexception-when-calling-iuser-getallroles/550</guid></item><item><title>Answer by Tho Tran</title><link>https://answers.axonivy.com/questions/548/permissiondeniedexception-when-calling-iuser-getallroles/549</link><description>&lt;p&gt;Login with "Developer" user&lt;/p&gt;
&lt;p&gt;Or&lt;/p&gt;
&lt;p&gt;Grant Developer's permission for your Test User role&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ivy.session.loginSessionUser("Developer","Developer");
ivy.wf.getApplication().getSecurityDescriptor().grantPermissions(ivy.wf.getApplication().getSecurityDescriptor().getSecurityDescriptorType().getRootPermissionGroup(),
                ivy.session.getSecurityContext().findRole("Everybody")
);
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tho Tran</dc:creator><pubDate>Wed, 26 Feb 2014 09:54:57 -0500</pubDate><guid>https://answers.axonivy.com/questions/548/permissiondeniedexception-when-calling-iuser-getallroles/549</guid></item></channel></rss>