cancel
Showing results for 
Search instead for 
Did you mean: 

What is the method isMemberOfRole in IUser class for?

Former Member
0 Kudos

Can anybody throw light on the purpose of the method

isMemberOfRole in the IUser class?

I have been trying to use it to compare user roles but without success.

IUser usr = WDClientUser.getCurrentUser().getSAPUser();

if(usr.isMemberOfRole("Test_Role",true))

{.....}

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

hi Meesum,

Go to user administration>roles in Portal

click start

It lists all the roles.The first column is the id.Identify the id of the role you want to check.Try giving it in isMemberOfRole()

Hope this helps you

Regards,

Rohit.

Message was edited by: Rohit Radhakrishnan

Former Member
0 Kudos

Cut-n-paste from API documentation:

<i>Checks if the principal belongs to the passed roleId This method does a recursive search if parameter recursive is set to true. If this user belongs to a group which is a member of a role, true is returned.</i>

<b>Parameters:</b>

uniqueIdOfRole - identifying the role

recursive - if true checks also all parent groups

<b>Returns:</b>

true if this user is directly or indirectly (via role membership) assigned.

VS

Former Member
0 Kudos

hi Meesum,

Check this link out

Regards

Rohit

Former Member
0 Kudos

Hi Meesum,

IUser.isMemberOfRole() takes the first parameter as the UniqueId of the role. I think the value you are providing is the display name for the role.

Hope this helps,

Best Regards,

Nibu.

former_member182372
Active Contributor
0 Kudos

Have you checked this ?

Former Member
0 Kudos

Hi,

Try this code

IWDClientUser user = WDClientUser.getCurrentUser();

IUser userID = user.getSAPUser();

String Userrole=new String();

for (Iterator iter = userID.getRoles(true); iter.hasNext();) {

IRole role = UMFactory.getRoleFactory().getRole((String) iter.next());

Userrole=role.getUniqueName();

}

You can use user.getSAPUser().isMemberOfGroup() method also

Regards, Anilkumar