Get Local IP address from NAV 2013 R2

navuser1navuser1 Member Posts: 1,324
edited 2017-04-11 in NAV Three Tier
Dear all,

How to get the IP Addresses of the (RTC) Client Machines who is accessing the NAV SERVER ?


Regards,
Navuser1
Now or Never

Answers

  • EvREvR Member Posts: 178
  • NavNabNavNab Member Posts: 179
    Hello,

    You can try this code

    ActiveSession.GET(SERVICEINSTANCEID, SESSIONID);
    IPAddresses:= IPAddresses.List;
    IPAddresses.AddRange(Dns.GetHostAddresses(ActiveSession."Client Computer Name"));
    FOR i := 0 TO IPAddresses.Count - 1 DO BEGIN
    MESSAGE('%1', IPAddresses.Item(i));
    END;

    Where variables:

    870745u1dw61.png


    P.S: the client machine may have more than one IP address.
  • NavNabNavNab Member Posts: 179
    I forgot to mention that you may need to adapt the code. It works for NAV 2016. I did not tested it for NAV 2013 R2
  • navuser1navuser1 Member Posts: 1,324
    edited 2017-04-12
    Few Local Machines are using RDP for accessing the NAV DB, I need to know their the Local IP address.

    Is it possible ?
    Now or Never
  • EvREvR Member Posts: 178
    Possible...well maybe technically. But you would have to get the client session (RDP session) to ask Windows (netstat or something more modern?) to give you the remote ip address. Sounds like adding a lot of error-prone complexity to me.
  • NavNabNavNab Member Posts: 179
    navuser1 wrote: »
    Few Local Machines are using RDP for accessing the NAV DB, I need to know their the Local IP address.

    Is it possible ?

    Hi navuser1,

    1- you should give feedback if the suggested solutions worked or not.
    2- it is not too difficult to say "thank you" to people who are trying to help you.
    3- you're asking a second question that is different from the first one.

    In another note, as suggested by EvR, you may use netstat and try to find the IP address through TCP port 3389 if default. Otherwise you should look for port value in registry key: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp]

    Another suggestion is to use the "Remote Desktop Services API reference".
  • navuser1navuser1 Member Posts: 1,324
    Thank you for your help.
    Now or Never
  • tabrezajaz@hotmail.com[email protected] Member Posts: 1
    edited 2017-09-21
    Hi, NavNab

    I am unable to create a variable of DotNet type for Dns.

    I didn't find Dns class there.
    Please help me......
  • NavNabNavNab Member Posts: 179
    Hello @[email protected]

    3u94j25062cj.jpg

    And you can download the object "COD92600_Get Local IP.txt"

    P.S: delete ".jpg" to get the correct object extension.
Sign In or Register to comment.