May 6, 2014

How to get the Ip Address of User using Apex in Salesforce?

String ipAddress = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');

'True-Client-IP' - when the request is coming via the caching integration.

'X-Salesforce-SIP' - when the request is not via caching integration (sandbox, developer edition orgs) or via the secure url.

Cheers!!!

2 comments:

  1. Could you please explain more, what do you mean by caching integration.???

    ReplyDelete
    Replies
    1. caching integration - sandbox, developer edition orgs.

      Cheers!!!

      Delete