web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

User IP address

(0) ShareShare
ReportReport
Posted on by 10

Hi All,

I'm looking for the user IP address to check against VPN, Tor, proxies list and all. Looking for end user IP, not server IP

I managed to get the IP address by writing a custom JS control that returns the IP address from JS on the client, and the user IP is correct...

But I'm wandering whether this property is saved somewhere in the local variables, such as session, xsession, users online, from IIS or else, and therefore I can get the value directly on the server.

Thanks

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: User IP address

    You should manage such checks in AAD, not D365FO.

  • André Arnaud de Calavon Profile Picture
    299,361 Super User 2025 Season 2 on at
    RE: User IP address

    Hi Enc@,

    Can you tell the purpose of this question? What is the business requirement here?

  • Enc@ Profile Picture
    10 on at
    RE: User IP address

    Thanks, so we have a user that is logging in the browser using a certain IP address. We have made a customisation that needs an accurate IP to check for IP Quality score using external providers, and surface result data into D365FO.

    At the moment we get the IP address using a new custom JS control that queries an external free API to return to our browser our own IP address... Which is not how I like to design things... but a temporary fix.

    As we're hosted on IIS, I expect there is a way for us to retrieve this IP, as well as user agent if possible. In php, we can get user IP using :

    $_SERVER['REMOTE_ADDR']

    $_SERVER['HTTP_USER_AGENT']

    $_SERVER['HTTP_ACCEPT_LANGUAGE']

    HttpContext.Current.Request.UserHostAddress;

    I'm looking for the user IP address, not server IP address.

    Thanks

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: User IP address

    Are you still sure that you need this data in D365FO? What is it used for? Just interested.

    You can use AAD to restrict access based on geography, IP address and so on, as well as view logs of logins.

  • Enc@ Profile Picture
    10 on at
    RE: User IP address

    It's not necessarly about blocking the user, it's also about creating a visual geo log of all changes that happened on some records, to be able to go back and know who did what, and from which IP address. As geolocation is related to IP, I'm trying to grab the client's IP from the server, rather than from the client.

    Hope this makes sense.

    Enc

  • MagVesse Profile Picture
    4 on at
    RE: User IP address

    Anyone has an idea on how to get this info?

    goshoomJoris dG

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: User IP address

    You can use the standard database log functionality to capture log of who changed what. Once you know that, you can check AAD logs and see from which IP/location the user logged in.

    Perhaps you can even develop some integration that would pull the data from AAD and show it in the D365FO database log form.

  • MagVesse Profile Picture
    4 on at
    RE: User IP address

    Thanks, I'm looking for a way to get the IP 'slightly faster' than having to contact AAD and query logs to retrieve user IP address.

    I'm really surprised that IIS is fully aware of user IP, but we're not able to grab it from X++... I'm sure I'm missing something here...

  • Suggested answer
    Joris dG Profile Picture
    17,775 on at
    RE: User IP address

    You cannot depend on infrastructure. In fact, some customers are already running D365 instances that don't use IIS. So taking that sort of dependency on abstracted infrastructure WILL guaranteed cause you problems in the future.

    The suggestion to use AAD for this is the correct one. Not to query logs, but rather to set policies how you allow logins to AAD to happen.

    See docs.microsoft.com/.../overview

  • MagVesse Profile Picture
    4 on at
    RE: User IP address

    Dear Joris,

    Thanks for your answer.

    I don't understand why getting IP is relying on abstracted infrastructure. To me, that infrastructure is the server side, and I do understand the D365FO server/service is likely to be behind high availability, therefore changing IPs and all.

    However, I'm after the user's IP, which is unlikely to change during the session, right? All client / server programming languages that I'm aware of allows to get the client IP (ASP, PHP, ...)

    Otherwise, do you know how I can request this IP from AAD? Somehow I feel this would be an overkill for what we're trying to achieve, but I'm willing to give it a look.

    Thanks for your help

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,047

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 885 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 592 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans