To Find IP Address of the User who login in Apex
• This is the very import as a developer prospective, normally we are tracking who user’s login name, date and time for monitoring purpose.
• But I saw so many scenarios, some users are sharing his credentials, which is totally wrong. So by using below code, we can track the Ip Address of The user. So, any issues we can caught him.
• It’s very important for user for those report, which are very important as company prospective.
• It’s available under owa_util package and another query available in Sys_context.
Query
SELECT OWA_UTIL.GET_CGI_ENV('REMOTE_ADDR') IP_ADDESS_APP_USER FROM DUAL;
SELECT SYS_CONTEXT('USERENV', 'IP_ADDRESS', 15) IP_ADDESS_APP_USER FROM DUAL;
we can write the code Process > After Header
BEGIN
INSERT INTO xxxxcomany_apex_report_history (
sa_username,
sa_report_name,
sa_page_id,
sa_viewed_date,
ip_address)
(SELECT
:APP_USER,
(SELECT s.text
FROM sify_procure_menu_ins s
WHERE 1 = 1 AND s.page_id = :APP_PAGE_ID)
text,
:APP_PAGE_ID,
SYSDATE,
(SELECT OWA_UTIL.GET_CGI_ENV('REMOTE_ADDR') IP_ADDESS_APP_USER FROM DUAL) AS IP_ADDRESS
FROM DUAL);
END;
