简体   繁体   English

在liferay中获取用户组描述和名称

[英]get user group description and name in liferay

I want to get the user group description as well the name of logged-in user in portlet. 我想获取用户组描述以及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. 这些用户组来自ldap,并映射到liferay DB UserGroup中。

Thanks in advance. 提前致谢。

As you have the user object, you can get full name of user by using 有了用户对象后,您可以通过使用获得用户的全名

user.getFullName() 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. 迭代列表以获取groupId。 Pass group Id to following method. 将组ID传递给以下方法。

Group grp = GroupLocalServiceUtil.getGroup(groupId)

You can get group Description using 您可以使用

String grpDisc = grp.getDescription();

Hope this is what you are looking for. 希望这是您想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM