Get the client name for a Terminal Services Session in a program
I am trying to get a reliable client name in a program for a Windows 2003 server terminal services session. (I am using Delphi but the question is really a Terminal Services question rather than a Delphi question). I read the environment variable 'CLIENTNAME' which works well most of the time but I have discovered the following problem.
If users log in on the SAME USER NAME so that there are multiple TS sessions under the same user name then even though they are logging from different computer names the 'CLIENTNAME' variable in all the sessions is set to the same value (the first or last one logged in I assume, I haven't checked in detail).
Is there a way around this so that the correct machine name or client name of the logged in user of the session that is running the program can be derived by the program, even for multiple logins for the same user name?
Any help would be gratefully appreciated.
Editors IDEsMicrosoft Server OSWindows Server 2003