Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

can we get the ip addres of an apex user?

EmuApr 17 2009 — edited May 3 2009
Is there anyway to get the ip address of an apex user?

Comments

Denes Kubicek
This should work


SELECT owa_util.get_cgi_env ('REMOTE_ADDR') FROM DUAL


Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.opal-consulting.de/training
http://apex.oracle.com/pls/otn/f?p=31517:1
-------------------------------------------------------------------
696924
--- good intentioned advice removed by author ---

Edited by: user5485835 on Apr 27, 2009 1:54 PM
MortenBraten
user5485835 wrote:
These seems to work well in APEX.


select SYS_CONTEXT('USERENV', 'IP_ADDRESS', 15) ipaddr from dual;
Based on my understanding, this would only give you the IP address of the actual database user connecting to the database during an Apex session (in other words, the ANONYMOUS user and the IP address of the database server itself if using the Embedded PL/SQL Gateway; or the APEX_PUBLIC_USER and the IP address of the webserver if using Apache).

To get the remote client's IP address you need to use owa_util.get_cgi_env as described in the first answer to this post.

- M
Emu
Actually I have (finally) got my app hosted on a remote server and.... select SYS_CONTEXT('USERENV', 'IP_ADDRESS', 15) ipaddr from dual; seems to be getting the IP address correctly.

Actually to maximise my chance at success in different environment (my app may be hosted elsewhere at some stage) I used this:

IF OWA.num_cgi_vars IS NOT NULL
THEN
-- PL/SQL gateway connection (WEB client)
return OWA_UTIL.get_cgi_env ('REMOTE_ADDR');
ELSE
-- Direct connection over tcp/ip network
return SYS_CONTEXT ('USERENV', 'IP_ADDRESS');
END IF;


:)
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 31 2009
Added on Apr 17 2009
4 comments
5,464 views