2

I am looking to do impersonation of Users other than standard LoginAs function from Visualforce.

Please give thoughts on this and directions.

Thanks in advance

2
  • what kind of impersonation are you trying to do? save that record as the user, show data as the user would see it, login as that user?
    – Ryan Guest
    Jan 24, 2014 at 8:09
  • I would like to Login as that User.
    – Arun SFDC
    Jan 26, 2014 at 14:07

1 Answer 1

1

If you want to render a VF Page as another user, you'll probably want to obtain their Session Id, then use an HTTP callout to render it. You can use a Cookie and pretend to be a browser:

String sessionId = UserInfo.getSessionId(); //you need THEIR sid
String url = 'https://c.na1.visual.force.com/apex/Vf';

HttpRequest request = new HttpRequest();
request.setEndpoint(url);
request.setHeader('Cookie', 'sid=' + sessionId + ';');
request.setMethod('GET');

HttpResponse response = new Http().send(request);
return response.getBody();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.