IP Address Logging

I need to record the IP address of anyone accessing my web core application.

How do I get the IP address?

Since the TMS WEB Core client application is running in the browser itself, this isn't the normal place where you would log the IP address, this is more typically done in the backend.
But there are some techniques & insights that can be helpful here:


Thanks, I will look at the code you referenced.

In this application, I will be logging into a XData Server.
Can I get the IP Address at that time?

If so, how?

Yes. In a XData server the IP address can be obtained using the following code:

TheIPAddress := TXDataOperationContext.Current.Request.RemoteIp;

I created an Auth.Service.Login unit similar to that in the xdata music demo.  In my application, I can only allow admin access for certain IP Addresses.

function TLoginService.Login(const User, Password: string): string;
  if ?RemoteIP? = '' then
    JWT.Claims.SetClaimOfType<boolean>('admin', User = 'admin')

How do I get the Remote IP Address in this context?

The way I mentioned above:

TheIPAddress := TXDataOperationContext.Current.Request.RemoteIp;
The answer I was seeking:
You must include XData.Server.Module in your unit.
It works now.

My TXDataOperationContext.Current.Request.RemoteIp is empty ... should I do something on client side?

What approach are you using to run your XData server? Http.sys dispatcher, Apache, Indy? Windows or Linux?

Linux ... this is apache module

For Apache we rely on Web Broker, which unfortunately doesn't implement retrieval of RemoteIP so such information is not available.

what a pity ... btw thx for the info

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.