Hacking Salesforce Account to Login

Suppose if you want to login to my Salesforce Account temporarily and I do not want to share my UserName & Password. Then what I can do is, I can generate a URL and share that URL with you.Now, by using that URL you can login from your machine.
*Terms & conditions apply 😜
To generate URL, below is the Code snippet :
string getSessionId=UserInfo.getOrganizationId().substring(0, 15) + ' ' + 
 UserInfo.getSessionId().substring(15);

string loginUrl=URL.getSalesforceBaseUrl().toExternalForm()+
'/secur/frontdoor.jsp?sid='+getSessionId;

System.debug('---You can Login with this URL ----'+loginUrl);

Note : From the above output, next to Orgid(org Id starts with 00D) it will generate an extra space that you need to remove before hitting this URL in browser.

tHiNk gooD and dO thE bEsT.........MANJU NATH 🌝

Comments

  1. Hi MANJU NATH,

    Thanks for this Great code Snippet.The above code only works for the org's where myDomain is not enabled.
    It would be great if you can resolve the same for the org's in which domain is enabled.

    Thanks
    Praveen

    ReplyDelete

Post a Comment