Tuesday, October 4, 2011

How to retrieve the Forms Client IP address ?

Visit the Below Website to access unlimited exam questions for all IT vendors and Get Oracle Certifications for FREE
http://www.free-online-exams.com
Problem: How to retrieve the Forms Client IP address ?

Symptoms:

I create trigger to Audit table X, i use this command to get ip_address
SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') from dual;
it returns application server ip, but i need the client machine ip


Solution:



In order to find the IP address of the "Client PC" (The PC where the Forma applet is running), it is necessary to execute some java code in the JVM executing the Forms Applet :

- I have first displayed the client_info for the current session
- I have added the client IP address with DBMS_APPLICATION_INFO.SET_CLIENT_INFO('IP=10.166.244.173');
- finaly, I have displayed the client_info for the current session


Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.4.2 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select client_info from v$session where audsid=sys_context('userenv','SESSIONID');

CLIENT_INFO
----------------------------------------------------------------


SQL> exec DBMS_APPLICATION_INFO.SET_CLIENT_INFO('IP=10.166.244.173');

PL/SQL procedure successfully completed.

SQL> select client_info from v$session where audsid=sys_context('userenv','SESSIONID');

CLIENT_INFO
----------------------------------------------------------------
IP=10.166.244.173

SQL>

References:


It is possible to create a java Bean :
Note 853971.1 How to Get the Physical IP Address of the Client Machine?

or use Webutil :
Note 403192.1 How To Get Client IP Address For a Locking User

For more details about WebUtil :
http://www.oracle.com/technology/products/forms/htdocs/webutil/webutil.htm

The WebUtil demo : http://www.oracle.com/technology/products/forms/htdocs/webutil/Webutil_demo.zip
implements an example Showing the Client IP Address.





Get Oracle Certifications for all Exams
Free Online Exams.com

No comments: