I have a common server administration account shared by a group of users in a Terminal Services Administrative environment.
Sometimes when logging on and all sessions are full, we'll just get the "Maximum number of connections" error.
Other times, it will log the other user off, give them the "Another user has connected to your session" error, and let them in.
What are the conditions that decides whether the other user will get logged off vs. max # of connections error?
If there is a disconnected session and you supply the same credentials then Terminal Services will re-attach to that session. Otherwise it will attempt to start a new session. If there are no more connections available you will get the Max # of connections error.
There are settings in the Terminal Services Configuration Manager to define how long before an idle session is set to a disconnected state.
Since everyone logs on with the same credentials you could potentially punk one of the other admins by running Terminal Services Manager, right-clicking their session, and selecting Connect from the context menu. You would see what they were running and they would get the Another user connected to the remote computer, so your connection was lost. message.
Careful with the terminology on this one. When a user connects via RDP and inputs the credentials for a user session that is currently active, the existing user isn't 'logged off', they're disconnected from the session. This means the new connecting user gets the session in whatever state it was in at the time of disconnection - open programs, processes and everything.
You're allowed 3 remote connections to a server running TS in Administration mode - 2 Remote Sessions and one 'Console' or 'Admin' session.
The Console session is the one that you'd get if you were stood in front of the server itself, looking at the monitor. You connect to it using the remote desktop exe with either /console or /admin switch (depending on your client windows version).
The key point with the admin console is that there's only ever one session in admin, so if you connect with any valid connections, you'll either take over the current admin session (if it's running with the same credentials) or you'll kick off the current console session and start a fresh one. When the latter happens, you'll be prompted to log off the existing user. When the former occurs, the logged off user will receive a notice, but the only clue for you is that the logon runs very quick, and there's stuff already open when you reach the desktop.
With the 2 remote connections (opened without /console or /admin) things are a bit different. You should never reach the console session, and you should be connected back to your existing session if one already exists and is in a 'Disconnected' state. If there's an existing remote session under your credentials, but in a 'connected' state, a new session will be started if there's a free slot. If there's no free slot, the existing session will be taken over. In cases where there's 2 remote sessions available under the same credentials, the one with the highest connection ID seems to be the one that gets taken over.
As an aside, you should ideally run under different administrative accounts and never share a single logon. If you ever get burned by an admin doing something they shouldn't, or for any other reason need to audit admin actions, you're going to be up a creek without a paddle. Yes, it's convenient, but avoid it wherever possible.