function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mroarkmroark 

Authenticating Customer Portal, Partner Portal, and Standard users via a single form?

Is it possible to authenticate Customer Portal, Partner Portal, and Standard users via a single form?

 

I have tried a few different approaches, and each errors on me.  Can anyone give me some feedback on whether this is possible, and what (if anything) I am doing wrong in the three approaches below.

 

1.  I tried setting up a SalesForce Site with authentication enabled using the SiteLogin page provided.  However, this does not work, as each Site must be tied to one, and only one, portal site, and does not work with Standard users.

 

2.  I tried using a SalesForce Site with public access enabled, and then tried using the AJAX Toolkit Javascript API.  The VisualForce page works fine if I am inside SalesForce for all three user types.  However, if I access the Site to run the page, I cannot authenticate.  Attempting to do so causes an error to occur on the login method.  This error is 'UNKNOWN_EXCEPTION: Site under construction'. 

 

However, if I enable the header and side bar, it works for standard and Partner Portal users, but not for Customer Portal users.  Attempting to login as a Customer Portal user fails with the following error message: 'INVALID_LOGIN: Invalid username, password, security token; or user locked out'

 

<apex:page showHeader="false" sidebar="false" >
<head>
<style>
page {width:100%;height=100%;border=1;background-color=red;}
</style>
</head>
<script src="../../soap/ajax/22.0/connection.js" type="text/javascript"></script>
<script type="text/javascript">
function validateUser()
{
alert("Username: "+document.getElementById("tbUsername").value);
try
{
var result = sforce.connection.login(document.getElementById("tbUsername").value, document.getElementById("tbPassword").value);
}
catch (e)
{
alert(e);
showStuff('lbLoginFailed');
return;
}
alert("result: "+result);
if (result != undefined)
{
showStuff('rnFrame');
hideStuff('theForm');
hideStuff('lbLoginFailed');
}
else
{
showStuff('lbLoginFailed');
}
}

function hideStuff(id) {
        document.getElementById(id).style.display = 'none';
    }
function showStuff(id) {
        document.getElementById(id).style.display = 'block';
        document.getElementById(id).style.width = '100%';
        document.getElementById(id).style.height = '1000px';
    }
</script>
<form id="theForm" width="100%" height="100%">

<table border="0">
<th><td colspan="2">Please login using your Customer Portal or <br/>Partner Portal credentials to access the article.</td></th>
<tr><td>Username:</td><td><input id="tbUsername" type="text"/></td></tr>
<tr><td>Password:</td><td><input id="tbPassword" type="password"/></td></tr>
<tr><td colspan="2" align="right"><input id="btnSubmit" type="button" value="Login" onclick="validateUser();"/></td></tr>
</table>
</form>
<div id="lbLoginFailed" style="display:none" >Login failed.  Please try again.</div>
</apex:page>

 

3. The last method I tried was using the SOAP API to create an ASP.Net page to try logging the user in.

 

This works for standard and Partner Portal users, but not for Customer Portal users.  Attempting to login as a Customer Portal user fails with the following error message: 'INVALID_LOGIN: Invalid username, password, security token; or user locked out'

 

BrendanOCBrendanOC

I'm not certain, but I believe this can be done using SAML SSO.  Check out this help topic for details:

https://<your instance>.salesforce.com/help/doc/user_ed.jsp?section=help&target=sso_tips.htm&loc=help&hash=heading_2_1

mroarkmroark

Brendan,

 

Thank you for the response, but SAML SSO is outside of the scope of my project. 

 

I'm trying to authenticate using only the standard API methods, or via an APEX page. 

 

Currently, I'm having users select their user type (customer portal, partner portal, or internal user), and then directing them to a page which performs the appropriate type of authentication.  This has met my business needs, but is somewhat cludgy, as I have to maintain 3 different pages for authentication.

BrendanOCBrendanOC

Partner and customer portal users require the PortalId to be specified as part of login, so its fundamentally a little different than standard login.

 

Off the top of my head, something like this may work:

 

Page asks for username/password.

 

Apex does a lookup where username = :usernameFromForm

Get the user's UserType

Route the authentication request to normal, partner portal, or customer portal based on User Type.

 

You'd be dynamically making the decision on which type of user they are within your Apex logic instead of asking the user to select normal, partner, or customer.  I'd need to play around with it a bit more to see if its possible, but it seems like that should work.