Subject Re: [firebird-support] Get client-IP-Adress
Author Mark Rotteveel
On 4-3-2019 10:04, Josef.Gschwendtner@... [firebird-support]
wrote:
> with our client software installed on a terminal server we like to get
> the IP-Adress of the "real" client-computer connected to the database
> (the one the user sits in front of).
>
> With Mon$Remote_Address from Mon$Attachments (using FB 2.5.8) we get the
> IP-Adress of the Citrix-machine.
>
> Is there a way to get the IP-Adress of the client-machine.
> Is there a difference/improvement using FB 3?

From the perspective of Firebird, the Citrix machine **is** the client.
The fact that the user remotes into the Citrix machine makes no
difference to Firebird, as the Citrix machine is what makes the actual
connection.

So, no there is nothing built-in in Firebird to do this automatically
(and I don't think there never will be). If you want something like
that, your application needs to take care of that itself (eg by setting
a variable in the USER_SESSION context).

For example, your application will need to obtain the client IP address
in some way (I don't know Citrix, so I don't know if and how that can be
done), then after connect, it needs to execute:

select RDB$SET_CONTEXT('USER_SESSION', 'CITRIX_CLIENT_IP', '<the ip
address>') from RDB$DATABASE

Subsequently, other parts of your application can get this using

select RDB$GET_CONTEXT('USER_SESSION', 'CITRIX_CLIENT_IP') from RDB$DATABASE

See also
https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-functions-scalarfuncs.html#fblangref25-functions-workcontext

Mark
--
Mark Rotteveel