Config and Licensing
G4S configuration is required in both Salesforce and .NET.
Salesforce
Follow the process of creating an API user, or editing an existing user, as outlined in the S4S documentation. You may need to change the names from S4S to G4S.
.NET
Your .NET application will need to be configured to use the connector against your Salesforce organization. G4S has two modes of operation, running as an application and running in a web context. Configuration requires making manual changes to your .NET configuration file (usually web.config for websites/web applications or app.config for standard applications).
Connection String
A connection string to Salesforce is required. Add a <connectionString> element to the config file
For Salesforce production and developer environments the connection string should look like:
<connectionStrings> <add name="G4SConnString" connectionString="G4S:user id=user;password=password;environment=login.salesforce.com" /> </connectionStrings>
For Salesforce sandbox environments the connection string should look like:
<connectionStrings> <add name="G4SConnString" connectionString="G4S:user id=user;password=password;environment=test.salesforce.com" /> </connectionStrings>
The <connectionStrings> element can have a number of connection strings defined. Each one is defined by the <add> tag. This element has a number of attributes but we use only two:
Attribute | Description |
Name | The name of the connection string. Any entity using this connection string will address it by this name. |
connectionString | The connection string itself. |
The login credentials and environment settings are then specified using the following:
Key | Description |
user id | The Salesforce username that will be used to establish the Partner API session |
password | The password for the Partner API user. |
token | (Optional) As an alternative to appending the user's security token to the password in the connection string, it can be defined separately to provide the same functionality. Learn more about how to reset and get your security token. |
environment | (Optional) The type of Salesforce environment being connected to. Defaults to Production if unspecified which will also work for developer edition organizations if required. Possible values:
|
Example connection strings:
S4S:user id=<user_name>;password=<user_password> S4S:user id=<user_name>;password=<user_password><user_security_token> S4S:user id=<user_name>;password=<user_password>;token=<user_security_token> S4S:user id=<user_name>;password=<user_password>;environment=<binding_environment>
The connection string can optionally define the environment to be connected to by appending the following:
;environment=<bindingEnvironment>
Permitted values for the binding environment are one of the following four strings or an endpoint url:
- Production
connects to login.salesforce.com (Default) - DeveloperEdition
connects to login.salesforce.com - Sandbox
connects to test.salesforce.com - Pre_release
connects to prerellogin.pre.salesforce.com
Licensing
To work against a production instance of Salesforce a G4S xml license file is required. The application needs to know how to find the license file so please adjust the .config file as follows.
Note the FuseIT.G4S.SalesforceConnector section name and the licenseFileLocation value is required.
<configuration> <configSections> <!-- ... --> <section name="FuseIT.G4S.SalesforceConnector" type="FuseIT.G4S.SalesforceConnector.SalesforceSettingsSection, FuseIT.G4S.SalesforceConnector"/> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> </configSections> <!-- ... --> <FuseIT.G4S.SalesforceConnector> <!-- timeOutMilliseconds: Indicates the time an XML Web service client waits for a synchronous XML Web service request to complete (in milliseconds). clientId: Partner application API token (Case sensitive). Required to work with Professional Edition orgs. uploadBatchSize: The maximum number of records that can be sent to Salesforce in an upload operation. This limit is defined by Salesforce. --> <binding timeOutMilliseconds="120000" clientId="" uploadBatchSize="200"/> <!-- Config to explicitly set the System.Net.ServicePointManager.SecurityProtocol --> <securityProtocols> <securityProtocol securityProtocolType="Tls"/> <securityProtocol securityProtocolType="Tls11"/> <securityProtocol securityProtocolType="Tls12"/> </securityProtocols> <!-- Speedup Keyprefix lookups for known values --> <keyPrefixes> <add key="Lead" value="00Q"/> <add key="Contact" value="003"/> <add key="User" value="005"/> <add key="Organization" value="00D"/> </keyPrefixes> <!-- The location of the G4SLicense.xml file provided by FuseIT --> <licenseFileLocation value="C:\SomePath\G4SLicense.xml" /> </FuseIT.G4S.SalesforceConnector> <!-- ... --> </configuration>