3

I have a Salesforce Communities site w/ user base set up, and I also have a custom web app (a CMS). I'm trying to allow my customers to log into my web app using their Salesforce username/password, while also logging them into the Community.

I don't necessarily need OAuth or SAML, but I'm very confused as to how I can/can't accomplish this with Salesforce. I've done something like this in the past with another "identity provider" where customer enters their username/password to my web app, the web app then calls an API to the identity provider, it validates the credentials and returns a user object along with a session id. I then set up an active session for them on my web app, and when they need to jump over to the identity provider's site, I can jump them over w/ the session id to let them in.

My instinct was to use the Salesforce enterprise SOAP API, and then frontdoor.jsp. I've tested this with some success, but the login() SOAP api method seemed to only work when I provided an OrgId and PortalId. I'm trying to authenticate users of the Salesforce Communities site, and then frontdoor them into the Community, not the portal.

Are there any resources that explain how to accomplish this?

Sample code:

loginClient = new SoapClient();

var lr = loginClient.login(new LoginScopeHeader
{
    organizationId = "{my org id}",
    //portalId = "??"  <-- not sure if this is necessary?
}, username, password);

var sessionId = lr.sessionId;

// TODO: compose frontdoor url with session id

Frontdoor.jsp says to compose a url w/ the following structure https://instance.salesforce.com/secur/frontdoor.jsp?sid=full_sessionID_value​&retURL=optional_relative_url_to_open but my communities portal is of the url structure https://my-community-name.cs27.force.com. I tried https://my-community-name.cs27.force.com/secur/frontdoor.jsp?sid=mysessionid but just got a page telling me to log in.

I understand the frontdoor documentation states "Not all session types are supported with frontdoor.jsp, such as community API sessions. For these sessions, consider using SAML for single sign-on, instead." But I don't even know what a "Community API session" means. I'm just using the regular SOAP api to call a login() method - what type of session is that?

Your Answer

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

Browse other questions tagged or ask your own question.