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:
- Follow all the steps mentioned in the documentation provided by the module author.
- Additional configurations for Salesforce
- Login to Salesforce using administrator account.
- Navigate to Create > Apps in the left-hand menu in the “Build” section.
- Open the connected app you created during Salesforce configuration.
- Click “Manage”.
- Click “Edit Policies”
- Set IP Relaxation to “Relax IP restrictions”. [This is required during development and for production you need to set IP restriction for better security.]
- Additional configurations for Salesforce connect for Sitecore module in Sitecore
- Open Sitecore.Salesforce.config.
- Provide userName and password.
- Also provide security token for the user by following the steps mentioned in the module documentation.
- TLS issue fix
- Download the source code for the module from GitHub.
- Open the Sitecore.Salesforce solution in Visual Studio.
- Open ClientBase.cs file from Sitecore.Salesforce.Client project.
- 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;
- Build the solution and deploy the latest assemblies to your Sitecore website.
- 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!!!