finding out client name for a user logging in to a remote server

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I have a requirement to display last successful logon for an account and the location from which that logon occurred. When a user logs on to a workstation the location would of course be the hostname of that workstation. I'm using Visual Basic Scripting to do this. It was working fine until today while I was of course showing it to our security person.

Even though I took into account when the user logs on to a workstation and the %CLIENTNAME% environment variable is not set, it seems that for some reason when logging onto a server %CLIENTNAME% can be set to "console" sometimes. This is strange considering I'm not asking for the Session Name which can be "console". I'm asking for the Client Name. When %CLIENTNAME% equals "console" when running my script or when running the 'set' command, if I look at the Users tab in Task Manager the Client Name is still the hostname of the maching I'm using to remote into the server.

Strangely, I thought that on the Users tab the Session Name would be listed as "console" when I use Remote Desktop to logon to the console of the server. I'm using Win2k3 R2. The Session name is always a RDP session # whether I connect to the console or not. But that's not something I'm worrying about at the moment.

Can anyone explain to me the circumstances that cause %CLIENTNAME% to be set to "console" as opposed to the user's workstation? I could test for it in my script if I knew the conditions under which it occurs. I'm currently using the following to grab the variable:
strFromHost = objShell.ExpandEnvironmentStrings("%CLIENTNAME%")

Thanks
Brandon
.



Relevant Pages

  • Re: finding out client name for a user logging in to a remote server
    ... workstation the location would of course be the hostname of that ... Even though I took into account when the user logs on to a workstation and ... the %CLIENTNAME% environment variable is not set, ... which can be "console". ...
    (microsoft.public.windows.server.active_directory)
  • Re: finding out client name for a user logging in to a remote server
    ... workstation the location would of course be the hostname of that ... Even though I took into account when the user logs on to a workstation ... some reason when logging onto a server %CLIENTNAME% can be set to ... Session Name which can be "console". ...
    (microsoft.public.windows.server.active_directory)
  • Re: finding out client name for a user logging in to a remote server
    ... Even though I took into account when the user logs on to a workstation and the %CLIENTNAME% environment variable is not set, it seems that for some reason when logging onto a server %CLIENTNAME% can be set to "console" sometimes. ... When %CLIENTNAME% equals "console" when running my script or when running the 'set' command, if I look at the Users tab in Task Manager the Client Name is still the hostname of the maching I'm using to remote into the server. ... The computername environment variable should always be the NetBIOS name of the local computer. ...
    (microsoft.public.windows.server.active_directory)
  • Re: finding out client name for a user logging in to a remote server
    ... When a user logs on to a workstation the location would of course be the hostname of that workstation. ... Even though I took into account when the user logs on to a workstation and the %CLIENTNAME% environment variable is not set, it seems that for some reason when logging onto a server %CLIENTNAME% can be set to "console" sometimes. ... Although I've been using my Win2k3 R2 servers for the majority of my testing, I have been using a couple XP workstations as well. ...
    (microsoft.public.windows.server.active_directory)
  • Re: SetConsoleCtrlHandler
    ... First of all the system isn't shutting down, ... application isn't a service and is not associated with a console. ... This modified handler does not call ... This allows the service to continue running after the user logs ...
    (microsoft.public.win32.programmer.kernel)