Salesforce connect for Sitecore module: Configuration and troubleshoot

Recently, I got a work to create POC for Salesforce integration with Sitecore. For the POC, I used the marketplace module Salesforce connect module. I followed all the steps mentioned in the documentation and tried to see whether the Salesforce contacts are getting listed in User Manager or not.

But, bad luck!

User Manager only listing the Sitecore users and not Salesforce contacts. Now its time for digging in log files.

While looking at logs I found that I was getting “authentication failure” exception while initialization of the SalesforceMembershipProvider. Can’t understand what was wrong because I’ve followed all instructions from document. However, after spending sometime for searching the resolution, I landed on GitHub for the same module where I found 3 issues where logged. Among 3 one mentioned about PasswordAuthenticator concatenates the password with the security token. And that stroked my mind that I’ve not provided password but only username and security token.

Also, after providing the Username + Password + Security token, I got the same exception of “authentication failure”. Again after spending time for finding resolution I found that in Salesforce we have to set IP Relaxation to Relax IP restrictions.

However, after performing all these settings, I was getting the same exception and at last I found that I need to communicate with Salesforce API over TLS 1.2. There are couple of ways to fix this issue which are mentioned in the following blog.

I fixed TLS issue by modifying the module code to set TLS 1.2 before sending the request to Salesforce API.

So, after doing all these exercise I thought I should write an article mentioning all the steps at one place. So, following are the steps to successfully configuring the module:

  1. Follow all the steps mentioned in the documentation provided by the module author.
  2. Additional configurations for Salesforce
    1. Login to Salesforce using administrator account.
    2. Navigate to Create > Apps in the left-hand menu in the “Build” section.
    3. Open the connected app you created during Salesforce configuration.
    4. Click “Manage”.
    5. Click “Edit Policies”
    6. Set IP Relaxation to “Relax IP restrictions”. [This is required during development and for production you need to set IP restriction for better security.]
  3. Additional configurations for Salesforce connect for Sitecore module in Sitecore
    1. Open Sitecore.Salesforce.config.
    2. Provide userName and password.
    3. Also provide security token for the user by following the steps mentioned in the module documentation.
  4. TLS issue fix
    1. Download the source code for the module from GitHub.
    2. Open the Sitecore.Salesforce solution in Visual Studio.
    3. Open ClientBase.cs file from Sitecore.Salesforce.Client project.
    4. Add following line at the beginning of EnsureHeaders method and save the changes.
      //Set TLS otherwise authentication failure exception will be thrown
      System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls;
    5. Build the solution and deploy the latest assemblies to your Sitecore website.
    6. I’ve updated the module source code by forking the original module and pushed it to GitHub. The updated code uses .NET Framework 4.6, Sitecore v8.2 rev. 161115. I’ve not change or removed any other files, so just consider the code changes.

That’s it. Happy Sitecore development!!!

Leave a Reply