Skip to main content
Hi, is there a way to get the ip address of the connected guest user?

I try the below code but it works for the logged user but returns null for the guest users:

@AuraEnabled

public static String GetUserIPAddress() {

string ReturnValue = Auth.SessionManagement.getCurrentSession().get('SourceIp');

I also try with a callout but it returns ip of salesforce server

 
2 answers
  1. Dec 11, 2018, 8:07 AM
    Hi,

    Greetings to you!

    You can use https://www.trackip.net/ip?json API to capture IP Address.

    Please refer to the below links which might help you further with the above requirement.

    https://developer.salesforce.com/forums/?id=9060G0000005Pc1QAE

    I hope it helps you.

    Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

    Thanks and Regards,

    Khan Anas
0/9000