Terminal Services Sessions: Then and Now
Windows NT was originally designed with a single interactive user in mind. Although multiple logon sessions were supported, only a single user had access to a “visible” logon session with desktops and windows. Desktops were contained in something called a window station and Windows NT had only one visible window station that the user could interact with. This
interactive window station was called Winsta0. In addition, all applications and logon sessions shared a global namespace for all named objects such as mutexes, timers, network drive letters, etc.
Windows 2000 introduced the Terminal Services environment that changed matters by allowing multiple users to log onto a computer interactively, either locally or remotely. Each user would receive a unique interactive window station called Winsta0 that was separate from other window stations with the same name. To achieve this separation, Windows introduced
Terminal Services. A Terminal Services session provided a container that further partitioned not only window stations but other named objects as well. These named objects were partitioned using namespaces. Objects shared across sessions were prefixed with “Global\” while objects specific to a given session were prefixed with “Local\”. Sessions were numbered starting from zero. The first interactive user shared the first session (e.g. session 0) with Windows services that always ran in session 0. Subsequent interactive users received new sessions (e.g. session 1, session 2, etc.). What this meant was that applications could no longer assume that they shared a window station with services. It also meant that named objects, which weren’t prefixed to indicate the namespace, would be created in the global namespace only if they happened to be running in session 0. Developers thus needed to be aware of the effects of multiple sessions when writing their applications.
Windows XP brought Terminal Services to the masses by building on it to implement features such as Fast User Switching and
Remote Desktop Connection.
Today Windows Vista and Windows Server 2008 continue to use Terminal Services to support multiple interactive local and remote users and again things haven’t really changed from a feature perspective. As long as your applications correctly identify whether named objects should be local or global and don’t assume they are running in session 0, you are fine. Windows Vista simply provides a wake-up call to developers who neglected to “pay their taxes” so to speak and didn’t make their applications Terminal Services aware in the days of Windows 2000 and XP. It does this by always creating a new session for interactive users. No longer is session 0 shared with the first interactive user so applications will most likely fail if they make any assumptions to that effect. Of course this change in Windows Vista is a positive: it was introduced to isolate services in order to better secure the operating system.
If you haven’t yet considered how Terminal Services sessions affect your application then now is the time!
Kenny Kerr
Senior Consultant, Lab49Read Kenny's blog