Security Token in Salesforce connectionstring

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Cloud Applications
Post Reply
nbcol
Posts: 5
Joined: Mon 19 Nov 2018 08:23

Security Token in Salesforce connectionstring

Post by nbcol » Mon 19 Nov 2018 08:33

Hello,
I'm using the Salesforce dotconnect version 5.0.2045.0.
I would like to provide the connectionstring via the constructor of Dbcontext. I tried the following value:
User Id=userid;Password=password;Security Token=securitytoken;Persist Security Info=True;Host=test.salesforce.com

I receive the following error:
Keyword not supported: 'security token'.

I then tried the SalesforceConnectionStringBuilder class:
Devart.Data.Salesforce.SalesforceConnectionStringBuilder sfCSB = new

Code: Select all

Devart.Data.Salesforce.SalesforceConnectionStringBuilder();
sfCSB.Host = "test.salesforce.com";
sfCSB.UserId = "userid";
sfCSB.Password = "password";
sfCSB.SecurityToken = "securitytoken";
sfCSB.MaxPoolSize = 150;
sfCSB.ConnectionTimeout = 30;
And used the connectionstring as generated by the class:

Code: Select all

sfCSB.ConnectionString
And I get the same error message.

Can you please provide me with the format I need to use for the connection string?

Thank you

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Security Token in Salesforce connectionstring

Post by Shalex » Mon 19 Nov 2018 19:43

You are using XML mapping, aren't you? Please try this code:

Code: Select all

        var sfCSB = new Devart.Data.Salesforce.SalesforceConnectionStringBuilder();
        sfCSB.Host = "test.salesforce.com";
        sfCSB.UserId = "userid";
        sfCSB.Password = "password";
        sfCSB.SecurityToken = "securitytoken";
        sfCSB.MaxPoolSize = 150;
        sfCSB.ConnectionTimeout = 30;

        EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
        entityBuilder.Provider = "Devart.Data.Salesforce";
        entityBuilder.ProviderConnectionString = sfCSB.ConnectionString;

        entityBuilder.Metadata = @"res://*/YourModel.csdl|res://*/YourModel.ssdl|res://*/YourModel.msl";

        using (Entities context = new Entities(entityBuilder.ToString())) {
            var a = context.MyEntity.First();
        }

nbcol
Posts: 5
Joined: Mon 19 Nov 2018 08:23

Re: Security Token in Salesforce connectionstring

Post by nbcol » Mon 26 Nov 2018 16:46

Hello,

I have tried the solution and it works well. Thank you!

ps is it possible to mark a question as done?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Security Token in Salesforce connectionstring

Post by Shalex » Tue 27 Nov 2018 10:34

nbcol wrote: Mon 26 Nov 2018 16:46is it possible to mark a question as done?
There is no way to mark a question as done.

Thank you for the confirmation that the issue is solved.

Post Reply