Tuesday, January 28, 2014

How to get Ip Address of User in Apex

How to get Ip Address of User in Apex

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

True-Client-IP has the value when the request is coming via the caching integration.
X-Salesforce-SIP has the value if there is no caching integration (sandbox, developer edition orgs) or via the secure url.
Thanks to TechNrd for this tips.


No comments:

Post a Comment