|
|||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Overview and BackgroundMicrosoft's terminal services client (also called 'Remote Desktop Connection') has one main thing against it. Remote applications do not appear as if they are running on the local desktop, instead they appear in a separate window which represents the server's desktop. This is fine if you just want to work exclusively on the server, but can be a pain if you want to switch between applications on the server and the local desktop or want to run applications on different servers. What is needed is a way to display the remoted applications as 'Seamless Windows' on the client. Commercial products have been written to achieve this in a Windows environment, the most well known would be Citrix. Citrix uses its own protocol (ICA) to publish applications to the client. Others have used Microsoft's protocol called RDP (Remote Desktop Protocol) with additional software to achieve the same effect (the most notable of these is Tarentalla's Canaveral IQ – I suspect they use a similar, but more sophisticated, method to the one presented in this article). While these products provide a lot more than just seamless windows, they are also quite expensive. It would be nice to have this feature in a regular RDP client without having to buy a whole application publishing product. This article provides a possible solution to this problem by extending Microsoft's RDP client using virtual channels to communicate between the server and the client. This option has been chosen over writing or extending an existing open source RDP client (such as rdesktop) because we will still be able to take advantage of all the features in Microsoft's client (and presumably all new features they add in the future). Also, an advantage to using Microsoft's client is that we can get some rudimentary application publishing over a web page since their terminal services client has an ActiveX component to do this. Concept And ApproachIntroductionThe RDP protocol does not provide any information about the open windows, all it does is send a bitmap of the server screen down to the client and route mouse and key presses back to the server. To make it appear that applications are running on the local machine, we need to 'clip' away the server desktop on the client. To do this, it is quite obvious that we are going to need to know what windows are on the server and where they are. For this, we can use global hooks to find out what is happening in the server session (windows opening, closing, minimizing etc.). Next, we need to communicate this information back to the client, this is where virtual channels come in. They are Microsoft's mechanism for two way communication between a server and client when a terminal services session is open. They are mainly used for transferring files and printing but we can use it to send window information back to the client. Once the client has this information, it can then use it to 'clip' the server desktop to just show the applications running on the server. Hooking into Window Messages On The ServerAt this point, I must give credit to Markus Rollmann. I have used his Code Project article as a basis to write this part of the software. This part of the application runs on the server and opens the server side of the virtual channel. To use global hooks, there is a separate DLL (called 'hookdll.dll'). This DLL monitors what is happening to the windows on the server and sends the appropriate string messages down the virtual channel which can then be interpreted by the client code. An interesting thing I learnt here is that you can't get Our application on the server ('clipper.exe') is now also our shell. When we launch our session from the client, we set the starting application as 'clipper.exe'. This ensures all the global hooks are setup before any applications are launched on the server. One of the parameters to 'clipper.exe' is the path of the application to start, which 'clipper.exe' launches as a new process. In addition, it will monitor this process so that when the process has exited, 'clipper.exe' can also close. This will then result in the session logging off as shell application has closed. Responding to the messages on the clientVirtual channels work by having an executable on the server sending information back to the client. On the client side, there is a DLL that is loaded by the terminal services client when it loads which can listen for the information coming down the virtual channels ('TswindowClipper.dll' – this is loaded by setting a key ( Publishing Applications On the WebIt is possible to launch a seamless terminal services session from a web page using the remote desktop ActiveX control. To do this, we need to tell it to use our client side Virtual channel DLL. This is how we do it: MsRdpClient.SecuredSettings.StartProgram = "c:\tswinclipper\clipper.exe notepad.exe"
MsRdpClient.AdvancedSettings.PluginDlls = "tswindowclipper.dll"
MsRdpClient.FullScreen = TRUE
MsRdpClient.Width = screen.width
MsRdpClient.Height = screen.height
We need to set the 'StartProgram' to the correct path for 'clipper.exe' and the application we want to launch on the server. Here is an example HTML file (your will need to get the 'msrdp.cab' file for the ActiveX control from here and put it in the same directory as this HTML page): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Remote Desktop Web Connection</title>
<meta content="JavaScript" name="vs_defaultClientScript">
</head>
<body>
<script language="vbscript">
sub BtnConnect
MsRdpClient.server = "<%YOUR SERVER%>"
MsRdpClient.UserName = "<%YOUR USERNAME%>"
MsRdpClient.AdvancedSettings.ClearTextPassword="<%YOUR PASSWORD%>"
MsRdpClient.Domain = "<%YOUR DOMAIN%>"
MsRdpClient.SecuredSettings.StartProgram = "c:\tswinclipper\clipper.exe notepad.exe"
MsRdpClient.AdvancedSettings.PluginDlls = "tswindowclipper.dll"
MsRdpClient.FullScreen = TRUE
MsRdpClient.Width = screen.width
MsRdpClient.Height = screen.height
'These 2 do not work from the activeX control
'MsRdpClient.AdvancedSettings2.DisplayConnectionBar = FALSE
'MsRdpClient.AdvancedSettings2.PinConnectionBar = TRUE
'Device redirection options
MsRdpClient.AdvancedSettings2.RedirectDrives = FALSE
MsRdpClient.AdvancedSettings2.RedirectPrinters = TRUE
MsRdpClient.AdvancedSettings2.RedirectPorts = FALSE
MsRdpClient.AdvancedSettings2.RedirectSmartCards = FALSE
'Connect
MsRdpClient.Connect
end sub
sub MsRdpClient_OnDisconnected(disconnectCode)
'goback to the page that called this one
history.go(-1)
end sub
</script>
<br>
<object language="vbscript" id="MsRdpClient" onreadystatechange="BtnConnect"
codebase="msrdp.cab#version=5,1,2600,1050"
classid="CLSID:9059f30f-4eb1-4bd2-9fdc-36f43a218f4a">
</object>
<br>
</body>
</html>
How To Install And RunHere are the main things to do:
There is a PDF called 'windowclipper.pdf' that is installed with the client setup. Have a look at that if you have any problems. Limitations
Acknowledgments
Revision History
|
||||||||||||||||||||||||||||||