Forums de discussion
How to get real user in portlet?
Gwowen Fu, modifié il y a 11 années.
How to get real user in portlet?
Expert Publications: 315 Date d'inscription: 27/12/10 Publications récentes
Hi,
After impersonating a user, how could I get the real user object or id?
Thanks!
Gwowen
After impersonating a user, how could I get the real user object or id?
Thanks!
Gwowen
mohammad azaruddin, modifié il y a 11 années.
RE: How to get real user in portlet?
Expert Publications: 492 Date d'inscription: 17/09/12 Publications récentes
ThemeDisplay td =(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
User user = td.getUser();
User user = td.getUser();
Gwowen Fu, modifié il y a 11 années.
RE: How to get real user in portlet?
Expert Publications: 315 Date d'inscription: 27/12/10 Publications récentesmohammad azaruddin:
ThemeDisplay td =(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
User user = td.getUser();
Tried that already and ThemeDisplay.getUser() returns the impersonated user, not the real user.
Also tried PortalUtil.getUserId(request) and it also returns the impersonated user ID.
David H Nebinger, modifié il y a 11 années.
RE: How to get real user in portlet?
Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
To get the real user id:
1. enable the com.liferay.portal.servlet.filters.audit.AuditFilter by setting it to true in portal-ext.properties.
2. use the following code:
Or you can do it the way AuditFilter does by getting the original http request, get the session from the request, then extract the WebKeys.USER_ID attribute.
1. enable the com.liferay.portal.servlet.filters.audit.AuditFilter by setting it to true in portal-ext.properties.
2. use the following code:
AuditRequestThreadLocal auditRequest = AuditRequestThreadLocal.getAuditThreadLocal();
if (auditRequest != null) realUserId = auditRequest.getRealUserId();
Or you can do it the way AuditFilter does by getting the original http request, get the session from the request, then extract the WebKeys.USER_ID attribute.
Gwowen Fu, modifié il y a 11 années.
RE: How to get real user in portlet? (Réponse)
Expert Publications: 315 Date d'inscription: 27/12/10 Publications récentes
Thanks for the reply. I missed the ThemeDisplay.getRealUser() method. ThemeDisplay.getRealUser() works.