Windows Server 2003 - checking TS sessions (remote desktop client)

30,647

Solution 1

Use Terminal Services Manager (in Administrative Tools) to connect to the server and see which sessions are still used. You can reset and logoff existing sessions from there. Remember that just closing the terminal session window does not log the session off. There are times, also, when network hiccups will kick someone out of a session resulting in a dangling session. I've seen it frequently where a VPN user gets booted off the VPN connection while connected to a terminal session. This nearly always results in a dangling terminal session in my environment.

EDIT: If you don't have TS Manager installed, install the additional admin tools from AdminPak.msi which is located in \Windows\System32 on the server.

Solution 2

As for how to deal with this remotely, you could install CopSSH on the server then run cmd when you get to the shell.

Then you can use query session to get the session ID and logoff to log the session off.

Like this:

Last login: Tue Jun  9 13:09:34 2009 from ip98-1xx-xxx-42.oc.xxx.xxxx.net

xxxxxx@xxxxxxxxxxx ~
$ cmd
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.


c:\xxxxxx\web\xxxxxx>query session
query session
 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>                  silverkey                 0  Disc    rdpwd
 rdp-tcp                                 65536  Listen  rdpwd
 console                                     2  Conn    wdcon

c:\xxxxx\web\xxxxx>logoff 0
logoff 0

c:\xxxxxx\web\xxxxxx>

Solution 3

On Server 2008 it has changed to Administrative Tools -> Remote Desktop Services -> Remote Desktop Services Manager

Solution 4

If you do not log of properly from an RDP session, but instead just close the window it will leave the session open, which is likely what is happening here.

If you are unabe to connect because there are too many sessions there are 2 options you can use to discconect these sessions:

  • you can connect directly to the console of the server using RDP, you can then use the Terminal Services Manager mmc to disconnect the other sessions. To connect to the console, run the following command from start->run. This will connect you directly to the console, and will log off anyone who is using it at the time.

    mstsc /v:serverIP /admin

  • If you are on the same local network as the server and have the Server 2003 admin tools installed you can connect the Terminal Services Manager console to that server and disconnect the users from your desktop.

Solution 5

Thanks Sam and squillman. Poking around a bit more I found the following helpful information:

To make this a bit easier and more foolproof:

  • Never log in to your server as administrator unless absolutely necessary
  • Create a secondary administrator user in the administrator group - use this when runas is not sufficient
  • Create user accounts for everyone that will be accessing the server
  • Don't give them administrator access - tell them to use runas when they need admin rights
  • Configure terminal services to allow each user only one login (ie, users can't login twice) this will force them to login to their currently connected account if they have a dangling login

-Adam

Share:
30,647
Adam Davis
Author by

Adam Davis

RIP Stack Exchange. codidact.org topanswers.xyz

Updated on September 17, 2022

Comments

  • Adam Davis
    Adam Davis over 1 year

    I have a VPS which is limited to 2 concurrent TS sessions. At one point I was locked out from signing in, even though all my previous sessions were closed.

    The provider indicated that the other sessions were still running, and they believe that I didn't actually "log off", so even if I exited the remote desktop client the server would still believe the connection was live.

    I've never had this issue with a regular computer, when I kill the connection in any manner it always disconnects gracefully and doesn't lock me out.

    • Does Windows 2003 have an issue with logging off properly when remote desktopping into it?
    • How would I clear this error, or in other words if I need to can I kick off any current connections given that I have admin access?
    • How do I check how many sessions are being used (assuming I can log in on a session)
    • Can I load VNC as a 'backup' tool, or what other tools can I use to more fully protect myself from this issue?

    -Adam

    • John Gardeniers
      John Gardeniers almost 15 years
      Have your provider set the time-out for disconnected sessions to prevent this happening in the future.
    • Matt
      Matt almost 15 years
      By "VPS" do you mean GoDaddy? I have a GoDaddy server and have the same problem and may have the some insight, but wanted to know your situation first.
    • Adam Davis
      Adam Davis almost 15 years
      No, it's a VPS with a different service, though for complete information, please add your suggestions to an answer below even if they are godaddy specific. It will help others in the future who have this issue.
    • Matt
      Matt almost 15 years
      With GoDaddy I actually end up ordering a reboot from them in order to get the sessions back. Its a pain, but it works. However if someone comes up with a better answer here I would love to use it instead.
  • Adam Davis
    Adam Davis almost 15 years
    Do I have to be on the same network to connect to the server via terminal services manager? This is a remote VPS over the internet...
  • squillman
    squillman almost 15 years
    Ah, good question. Sorry I didn't catch that in your post, but I see it reading between the lines. It certainly helps if you are, but I'm not 100% certain if you MUST be. I expect you do. I also seriously doubt that your provider would have the access open in order to do so if it is possible...
  • Adam Davis
    Adam Davis almost 15 years
    Yeah, it doesn't look like I want that kind of thing open over the internet anyway. Still trying to figure out how to login when there all the slots are full though... Need a way to reset a session remotely.
  • scobi
    scobi almost 15 years
    Thanks for the followup. Particularly about the option to permit one session per user. I never thought to look for something like that.
  • user1124702
    user1124702 almost 15 years
    @Adam ... look at my answer below for another alternative.