Getting User Groups/Roles

I tried searching a bit on the forums but could not find anything relevant.:o
I want to get a list of MWS groups that a user belongs to. Similarly for Roles.
Is there an API function that can do it?:confused:
I could see that I can get the user name by using getFacesContext().getExternalContext().getRemoteUser();

You can use the following:
UserModel user = new UserModel();
List groups = user.getGroupMembership();
Iterator it = groups.iterator();
String group = null;

while (it.hasNext()) {
group = ((GroupModel)it.next()).getPrincipalID();

…
}

For roles, use user.getRoleMembership();

Hope this help

very helpful.
Many thanks !