function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Neil WylieNeil Wylie 

Security Tokens

    I have developed an application in Visual Basic 6 that logs into SalesForce successfully. The application runs successfully in VB, but when I compile it and run it as a standalone prorgramme, the login fails.
    With a view to understanding this problem, I have created identical applications in Access and Excel, and used the same login method as in vb - both fail. The Access application in particular uses identical code.
    This problem has only arisen since Sales Force introduced the concept of concatinated passwords and security tokens.

Has anyone else had this problem, and if so, is there a workaround? Code snippets are attached.

Thanks,

Neil

Code Snippets:
'Log into SalesForce
If SampleLogin(Me.txtSF_User, Me.txtSF_Password) = True Then
    MsgBox "Logged in", vbOKOnly, "SalesForce"
    'CreateAccount
Else
    MsgBox "Login Failed"
    Unload Me

Public Function SampleLogin(Username, Password) As Boolean
Set g_SFApi = New SForceOfficeToolkitLib3.SForceSession3
SampleLogin = g_SFApi.Login(Me.txtSF_User, Me.txtSF_Password)
End Function


jmarinchakjmarinchak
Since the introduction of security tokens, I've found that my VBA programs pretty much always require that the security token is added to the password.  Does the code work if you add your security token to the password?
 
Jeff
Neil WylieNeil Wylie
Hi Jeff,

Thanks for the reply. Yes, my password includes the original version and the security token as a concatinated string, and no, it doesn't work. As a possibly related point,  I am working on a desktp and laptop - do you know if i need a separate security token for each machine, or is this simply login sensitive?

Thanks,

Neil
jmarinchakjmarinchak
Neil,
 
I made a few modifications to your code to get it working.  This version should work.  I think your problem may have been related to the variables in the SampleLogin function not getting the username and password.
 
Jeff
 
Code:
Dim g_sfApi As SForceOfficeToolkitLib3.SForceSession3

Sub MyMain()
If SampleLogin("your user name", "your password + security token") = True Then
    MsgBox "Logged in"
    'CreateAccount
Else
    MsgBox "Login Failed"
    'Unload Me
End If

End Sub

Public Function SampleLogin(Username, Password) As Boolean
    Set g_sfApi = New SForceOfficeToolkitLib3.SForceSession3
    SampleLogin = g_sfApi.Login(Username, Password)
End Function

 
 

 
Neil WylieNeil Wylie
Bingo!!!   Thank you very much. Interestingly, my version works with the VB app. With regard to the security token being machine or login specific, any ideas?

Neil
jmarinchakjmarinchak

I think the security token is machine independent.  If you include your security token with your password, I *think* you can login from *any* machine.

Jeff