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
BerettaJonBerettaJon 

How to validate credentials and do a cross org query?

Hi SF peoples,

 

Here's what I have been challenged with.  My team has a public facing website/form that when filled out will automatically generate a lead inside my org.  I want the people filling out the site/form to enter their SF credentials (username,password,securitytoken) so that we can set up some API access.

 

Is there anyway that I can validate the given user credentials and perform a query from within my org using a trigger on the Lead or something similar?  I want to be able to get the email entered in their salesforce org for that specific set of credentials.

 

Im not really aware of any cross org stuff, another developer is the one diving into the API stuff, Im more of the Triggers and VisualForce guy... Could someone point me in the right direction or let me know if this is impossible?

 

.001 BTC reward for good info :)

digamber.prasaddigamber.prasad

Hi,

 

Unfortunately, this is something not possible in salesforce.

BerettaJonBerettaJon

Here is the solution I came up with 

 

trigger ValidateCredentials on Lead (before insert) 
{
for(Lead l : Trigger.new)
{
LeadWebService.WSDLConnectionTest(l.username__c,l.password__c,l.token__c);
}
}

 

global class LeadWebService
{
 @future(callout=true)
    public static void WSDLConnectionTest(String uName,String uPassword,String uToken)
    {
 
        partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap(); // Class generated by Partner's API
        partnerSoapSforceCom.LoginResult LoginResult = myPartnerSoap .login(uName,uPassword+uToken);
        system.debug('____________Login Successful_______________________'+LoginResult);
    }
}

 The validation happens as an asyncrounus API call.  I will be able to send an email containing the info I need using this.