Skip to Main Content

Oracle Forms

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.

How to get client machine name from database ?

9189Sep 4 2008 — edited Oct 7 2008
Hiya

As part of the user authentication in our application, the requirement is that if a user has logged in from one machine, the same user cannnot login from different machine at the same time.

In Forms6i, we had accomplished this using the following query:

Select Terminal
From v$session
Where username = v_username
And terminal <> v_terminal;

Where
v_username = USER -> Oracle Forms Reserve Word
v_terminal = Client_Win_API_Environment.Get_Windows_Username

In Forms 6i, the Terminal column of V$Session used to return the name of the local client machine.

However, in Forms 10g, it returns the machine name on which Oracle Application Server is installed, which I believe is correct.

So my question is how do we get the client machine name from database in the context of Oracle Forms 10g ? Is there another view/table or database package that returns the client machine name ?

Your suggestions/comments will be much appreciated.

Cheers

Mayur
This post has been answered by Andreas Leidner on Sep 4 2008
Jump to Answer

Comments

Tony Garabedian
Use the SYS_CONTEXT to return the client machine name in forms 10g
SYS_CONTEXT('USERENV', 'TERMINAL')
For the operating system identifier for the client of the current session.
SYS_CONTEXT('USERENV', 'OS_USER')
For the operating system user name of the client process that initiated the database session.
SYS_CONTEXT('USERENV', 'SESSION_USER')
For enterprises users, returns the schema. For other users, returns the database user name by which the current user is authenticated. This value remains the same throughout the duration of the session.

Using the OS_USER you can further make sure that the user is only logged on to the OS with his/her own username.


Tony

Edited by: Tony Garabedian on Sep 4, 2008 1:00 PM
9189
Hi Tony

Many thanks for your quick reply.

I have just now tested your solution. However, I am afraid, it didn't work. The query

Select SYS_CONTEXT('USERENV','TERMINAL')
from Dual

used in the Forms 10g, still returns the machine name of Application Server and NOT the client machine name.

Cheers
Mayur
Tony Garabedian
Sorry, my bad, again I didn't realize I was logged in on the Application server when I was testing.

The most easy solution is to use webutil's get client info package this package will help you to get most of client's machine information.

You can download these packages from [Forms 10g Demo|http://www.oracle.com/technology/sample_code/products/forms/index.html]


Hope this helps


Tony
Hafed Benteftifa
Hello,

Just to add to Tony's suggestion, download the webutil Forms demo FMB. It has examples of the webutil statements for getting all sorts of info about the client.
Adina -Oracle
In addition to the above,maybe it helps to know that Webutil functions are :

Webutil_clientinfo.get_host_name
Webutil_clientinfo.get_ip_address

and Webutil Demo : http://www.oracle.com/technology/products/forms/htdocs/webutil/Webutil_demo.zip
Andreas Leidner
Answer
We've implemented the exact same requirement by fetching the client's IP address (WebUtil provides a function for that) and writing it into the field v$session.action (this can be done using the DB package dbms_application_info). So in Forms 10g we're evaluating v$session.action instead of v$session.terminal.
Marked as Answer by 9189 · Sep 27 2020
Tony Garabedian
leidner wrote:
We've implemented the exact same requirement by fetching the client's IP address (WebUtil provides a function for that) and writing it into the field v$session.action (this can be done using the DB package dbms_application_info). So in Forms 10g we're evaluating v$session.action instead of v$session.terminal.
I wouldn't recommend that, leave the action for what's the application/module/form is doing, and which transaction or batch processing is running. You should write any information regarding the client in the CLIENT_INFO and not the ACTION.


Tony
Andreas Leidner
Well, we didn't use the action field before (and Forms itself doesn't seem to use it either) and it's only used temporarily during the logon process now. Anyway, we're already using hte client_info field for another purpose and its length is limited to only 64 bytes I think so we cannot use that. And "logging on with IP ..." just looks like an action to me :)
Tony Garabedian
Yes the CLIENT_INFO is limited to 64 bytes, we populate values in it only separated with an " ! " and we have a function that returns the needed value of the passed number parameter.


Tony
9189
Thanks to Tony, leidner and other contributors to this thread for your inputs.

I have liked the suggestion of leidner to use Action column of V$Session to store the local machine name using DBMS_APPLICATION_INFO package although I completely agree with Tony that Action column should not be used for such purpose.

For those of you who have suggested to use Webutil, I would like to highlight that for my this requirement Webutil cannot be used. This is because Webutil returns the information for the user's current machine to which he is connected to. It will not give you the details for other users' machine.

To make it more clear, conside this example:

Lets assume that there are two machines, MACHINE-A and MACHINE-B. USER-A is connected to MACHINE-A and USER-B is connected to MACHINE-B. Webutil will give the details to USER-A for MACHINE-A only. While being connected to MACHINE-A, USER-A cannot get the details of MACHINE-B.

In view of this requirement, the only option for me was to use something from database either by using Oracle's views like V$SESSION, package like DBMS_APPLICATION_INFO or write our own customised stored procedures/ packages.

Cheers
Mayur
Tony Garabedian
I strongly suggest you to use the CLIENT_INFO and not the ACTION.

ACTION column is used by Oracle database, Application Server and many other Oracle and third party tools, and that's why they have the CLIENT_INFO column. If think this is not enough, try to store only useful information.


For your requirement to have information stored about the user sessions, why you want to re-invent the wheel :) ??? The application server already does that for you in the session logs for each session under %ORACLE_HOME/forms/em/em_[ pid ].rti files, these are flat files that can be read using TEXT_IO.
This way you can read any user's complete session information from any other users.

To view Forms Session information in the EM / AS console, set the Forms applet parameters em_mode=1 and allow_debug=true. This method among others are clearly explained in metalink Note: 97580.1


Tony
abhikale
Hi,

I am also facing the same problem.

The Dbms_Application_Info does work but is not 100% solution to the problem. Let me explain in detail.

Oracle user A logs in to http://....com/forms/frmservlet?config=default&form=machinename.fmx from Machine A
Same user A logs in to http://....com/forms/frmservlet?config=default&form=machinename.fmx from Machine B

machinename.fmx has button which when clicked should return Machine A or Machine B when button is clicked
I cant use webutil and text_io as they work from front end only, requirement is to get it from backend
So, as a test case, this machinename.fmx has a button, which calls a backend function returning the machine name...using syscontext/v$session is not working.

The actual requirement is that - in the application when a user performs any action, it writes/updates many tables, say 3. There is trigger on these 3 tables which should capture the machine name from which action is performed and update the machinename column in those tables. This works well in client/server environment - forms 6i - syscontext, etc work.

I am looking for alternative in 10g.

Early reply is appreciated.

Thanks,
Abhijit
Tony Garabedian
If you have read the threads you posted in you would have found the solution :)

You are working in 3 tier architecture, the functions that work in Forms 6i might not work in 10g, to get the client IP address, machine name etc... you need to use webutil's function as stated in this thread.

If you have other problems please post your question in a new thread.


Tony
1 - 13
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 4 2008
Added on Sep 4 2008
13 comments
8,968 views