I want to get the user group description as well the name of logged-in user in portlet. I am able to get the logged-in user object using:
ThemeDisplay td = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
User user = td.getUser();
Please help me out with how to get the logged-in user's group. These user groups are coming from ldap and mapped in liferay DB UserGroup.
Thanks in advance.
As you have the user object, you can get full name of user by using
user.getFullName()
for getting the user group description, call the following method, which will give you the list of Groups. which belongs to user.
List <Group> grpList = GroupLocalServiceUtil.getUserGroups(userId);
Iterate the list to get the groupId's. Pass group Id to following method.
Group grp = GroupLocalServiceUtil.getGroup(groupId)
You can get group Description using
String grpDisc = grp.getDescription();
Hope this is what you are looking for.