How to fetch remote IP address

Posted by Harrie Kuijper on 16-Jul-2015 04:16

Hi,

I'm looking for a way to get the remote ip address (of the user logged in). Is there a way to do this at the serverside, in a trigger for example? Without hosting a JSP file which fetches this.

I want to track from what IP address an object is created from in a onCreate trigger.

Regards,

Harrie.

Posted by Srinivas Panyala on 24-Jul-2015 01:02

Hi Harrie,

You can get IP address from client side to server side using Html events. But it requires user interaction. Just sharing my thought, I am not sure it works for you.

Steps:

1) Create a text box field

2) Click on Events link of above-created textbox(Object Definition -> Fields section)

3) Enter "myIP();" as value for onfocus event

4) Move to new record page

5) Click on Design this page

6) Add script component

7) Paste below script & save

<script>

function myIP() {  

ajaxRreq = rbf_getXMLHTTPRequest();  

if (ajaxRreq) {      

   ajaxRreq.open('GET', 'https://api.ipify.org', false);    

   ajaxRreq.setRequestHeader('Content-Type', 'application/text; charset=UTF-8');

   ajaxRreq.send();        

  document.getElementById("IPAddresssText").value = ajaxRreq.responseText.toString();          

}  

}

</script>  

8) While creating new record focus once on above created text box. It will fetch the IP address and set the value

9) Save the record.

Thanks

Srinivas

All Replies

Posted by Harrie Kuijper on 21-Jul-2015 08:59

Nobody? :-/

Posted by Tom Kincaid on 21-Jul-2015 15:23
 
I don’t believe there is any way to do this. Others?
 
Tom
 
 
[collapse]
From: Harrie Kuijper [mailto:bounce-hkuijper@community.progress.com]
Sent: Tuesday, July 21, 2015 10:00 AM
To: TU.Rollbase@community.progress.com
Subject: RE: [Technical Users - Rollbase] How to fetch remote IP address
 
Reply by Harrie Kuijper

Nobody? :-/

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]
Posted by pvorobie on 21-Jul-2015 16:46

I agree: this is not possible with current framework.

Posted by Ricardo Rafols on 22-Jul-2015 06:50

Hi Harrie,

Server-side, you can use the code creating a trigger type “Update Field Value”:

rbv_api.sendJSONRequest("https://api.ipify.org", null, "GET", "application/text; charset=UTF-8" , null, null, null);

Client-side, you can use the code inside a script component:

<script>

function myIP() {  

 ajaxRreq = rbf_getXMLHTTPRequest();  

 if (ajaxRreq) {          

    ajaxRreq.open('GET', 'https://api.ipify.org', false);    

    ajaxRreq.setRequestHeader('Content-Type', 'application/text; charset=UTF-8');

    ajaxRreq.send();        

   document.getElementById("ip").innerHTML = ajaxRreq.responseText.toString();          

 }  

}

</script>  

<div id="ip"> <script> myIP(); </script></div>  

It’ll return the user IP on server-side and/or client-side ...

Regards,

Ricardo

Posted by Tom Kincaid on 22-Jul-2015 06:54

Clever! Thanks Ricardo!

Posted by Harrie Kuijper on 22-Jul-2015 09:55

Thanks! I will try the clientside approach, since I will get back the server's ip address instead of the users ip address using the serverside code.

Getting the users ip address needs a custom JSP I think.

Regards,

Harrie.

Posted by Srinivas Panyala on 24-Jul-2015 01:02

Hi Harrie,

You can get IP address from client side to server side using Html events. But it requires user interaction. Just sharing my thought, I am not sure it works for you.

Steps:

1) Create a text box field

2) Click on Events link of above-created textbox(Object Definition -> Fields section)

3) Enter "myIP();" as value for onfocus event

4) Move to new record page

5) Click on Design this page

6) Add script component

7) Paste below script & save

<script>

function myIP() {  

ajaxRreq = rbf_getXMLHTTPRequest();  

if (ajaxRreq) {      

   ajaxRreq.open('GET', 'https://api.ipify.org', false);    

   ajaxRreq.setRequestHeader('Content-Type', 'application/text; charset=UTF-8');

   ajaxRreq.send();        

  document.getElementById("IPAddresssText").value = ajaxRreq.responseText.toString();          

}  

}

</script>  

8) While creating new record focus once on above created text box. It will fetch the IP address and set the value

9) Save the record.

Thanks

Srinivas

This thread is closed