How to impersonate liferay user using API?

thumbnail
1201319, modified 17 Years ago. Junior Member Posts: 39 Join Date: 8/20/08 Recent Posts
Hi,

I need to impersonate user using JSF portlet.
Please suggest me how to impersonate user using liferay API.

Regards,
Lok
737596, modified 17 Years ago. New Member Posts: 3 Join Date: 4/28/08 Recent Posts
I have the same problem.
Anyone has a solution?
thumbnail
4317357, modified 15 Years ago. New Member Posts: 4 Join Date: 11/25/09 Recent Posts
To impersonate user outside from Control Panel you just need to generate "magic" parameter (doAsUserId=) which contains encrypted target user id. I used liferay-security tag for that:


<liferay-security:doasurl doAsUserId="${command.doAsUserId}" var="impersonateUserURL" />


You can manually "encrypt" paroper parameter value, just look for examples in com.liferay.taglib.security.DoAsURLTag sources :-)

Real user needs to have permission to impersonate. This can be defined in custom role (regular) with portal permission User: Impersonate: scope=portal
6559699, modified 15 Years ago. New Member Posts: 7 Join Date: 11/22/10 Recent Posts
Hi,

I want to update some data in table when the impersonation happens.Any idea on this.

regard
neha
5395904, modified 15 Years ago. Junior Member Posts: 39 Join Date: 7/23/10 Recent Posts
Igor Popik:
To impersonate user outside from Control Panel you just need to generate "magic" parameter (doAsUserId=) which contains encrypted target user id. I used liferay-security tag for that:


<liferay-security:doasurl doAsUserId="${command.doAsUserId}" var="impersonateUserURL" />


You can manually "encrypt" paroper parameter value, just look for examples in com.liferay.taglib.security.DoAsURLTag sources :-)

Real user needs to have permission to impersonate. This can be defined in custom role (regular) with portal permission User: Impersonate: scope=portal


Can you elaborate how to use this within the context of a portlet form?
I'm trying to create a list of users in a select box and on change, initiate the impersonation of that user.

Thanks in advance.