On the Contact detail page there is a Work With Portal -> Login As Portal User button when the Customer Portal is enabled. I have a Force.com Site that uses Customer Portal for authentication. When an internal SF user clicks on that button link it takes them to the unbranded standard SF portal. I would like it to log them in to the skinned site. How can that be done? I didn't find any documentation on this, but maybe I just missed it.

I tried just copying and pasting in the url of the secure site after clicking the Login As Portal button link, but I guess a different cookie is used or something because it didn't recognize that I was logged in.

To be clear, it is this button on the Contact page. The desired functionality is that the internal user that has access to the Contact can log in to the Force.com Site that uses Customer Portal for the authentication. I'm not asking how to use set up Force.com Sites + Customer Portal for a skinned log in. It's the logging in as the Contact user to the skinned site that that I'm interested in.

Login As Portal


3 Answers 3


I did this on our site. I made a homepage component and assigned it to the customer portal home page. It's just a link to /apex/thepageyouwanttostarton.

So the process is login-as, click the link, then you're on the page you wanted.

The catch here is that the internal logging-in-as user is the only one whoever sees this because the customers log in from the site, never hitting the actual portal home page.

  • In addition to the link, I added a bit of javascript to automatically set the page to the site's home page. Commented Dec 13, 2012 at 17:26

There isn't a method to use the 'Login As' and view the portal through a Site. In order to view the portal through the Site, you will need to sign in just as the user does on the Site themselves with that user's username and password.

An alternative is to additionally skin the Customer Portal itself using HTML fragments for the Customer Portal Header and Footer elements.

Setup > Customize > Customer Portal > Settings > (Header, Footer)

Each of these fragments should be stored as Document records with the 'Externally Available Image' checkbox checked.

Your Header document would contain something like:

        <link rel="stylesheet" type="text/css" href="/resource/yourstaticresource/yourstylesheet.css" />
        <div id="bodyContent">

Your Footer document would contain something like:


At that point the #bodyContent div will be wrapped around the native Customer Portal body and you'll have a customer portal with your defined look and feel when using the 'Login As' feature as well as the separately defined Site configuration.


I don't believe a standard user can login as one of your portal users. I'm thinking this would be a security problem since it's not as if some System Admin of a company logs in as another employee of that company. That is to be expected. But logging in as an outside portal user, presumably without them knowing it, would break the contract of trust, no?

But in order for internal users to experience a site with the skin intact, all you need to do is make sure the access rights of the users in question permit viewing the site. Then just create a tab that points to the home page of your site and users can click through to the skinned version. I use this technique to quickly view my code/UI changes during development. If needed, you can create a dummy contact/user (work with portal) that internal users can login as from the home page of your site.

On a related note, here's a method to use custom usernames and passwords to allow high volume portal users to login to your sites (assuming the custom login name is forced to be unique and the custom password matches the actual password):

private static String endPoint = 'https://cs4.salesforce.com/secur/login_portal.jsporgId=XXXXXORGIDXXXXXX&portalId=XXXXXXPORTALIDXXXXXX';
private static String orgId = userInfo.getOrganizationId();
private static String portalId = 'XXXXXXPORTALIDXXXXXXX';

public PageReference login()
   PageReference p = null;
   if(login != null && password != null )
      List<User> users = [SELECT Id, Username, FederationIdentifier, IsPortalEnabled, IsActive, Contact.YourCustomLoginName__c, Contact.YourCustomPassword__c, ContactId 
         FROM User
         WHERE Contact.YourCustomLoginName__c = :login 
         AND Contact.YourCustomPassword__c = :password 
         AND IsPortalEnabled = TRUE
         AND IsActive = TRUE 
         LIMIT 1];
      if(users.size() == 1)
         p = new PageReference(endPoint+'&un='+users[0].Username+'&pw='+password);


   return p;

Then you can use the following to make sure that when they change their custom password that their actual password changes along with it:

System.setPassword(user.Id, Contact.YourCustomPassword__c);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .