Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

This code block shows how to login to Sitecore with credentials stored in Salesforce. Note the Salesforce domain is used by Sitecore to identify if the member comes from Salesforce.

/// <summary>
/// Attempts to authenticate a user against Salesforce Contacts and Leads
/// </summary>
private void LoginUser(string userName, string password)
{
    string domainContacts = "salesforce\\";
    string domainLeads = "salesforceLead\\";
            
    //Attempt to authenticate against Salesforce Contacts
    string sfUser = string.Concat(domainContacts, userName);
 
if(Sitecore.Security.Authentication.AuthenticationManager.Login(sfUser, password))
    {
        //User is authenticated against Salesforce Contacts
    }
    else
    {
        //Attempt to authenticate against Salesforce Leads
        sfUser = string.Concat(domainLeads, userName);
 
        if (Sitecore.Security.Authentication.AuthenticationManager.Login(sfUser, password))
        {
            //User is authenticated against Salesforce Leads
        }
    }
}
  • No labels