Get the Client Name of your (Remote) Machine in AX2012
In this short post I want to highlight how you can get the name of the client which is connected to AX 2012, even if you run your session via a RDP connection. For this purpose I wrote a small Job, that outputs the client name in an Infolog.
|static void GetClientNames(Args _args)|
|// TS Host|
The first Info invokes the static global method computerName(), which will return the client name from the machine that runs the AX 2012 client right now. Unfortunately, if you are running AX 2012 on a terminal server, it will return the hostname of that server, not the name of your actual “local” client.
So the second method makes use of some .NET code and reads the client name directly from the Environment class. The static method GetEnvironment() takes an argument as string, to get the client name, just pass “CLIENTNAME”.
In the screenshot below one can see the output, the first Info is from a terminal server, the info below from a local machine.