How to RDP from a web page

You can create the .RDP file on the server side, which Windows should associate with Remote Desktop, and force the browser to download it (instead of displaying it). In PHP you would do it like this:

$file = 'screen mode id:i:2
desktopwidth:i:1436
desktopheight:i:925
session bpp:i:16
auto connect:i:1
full address:s:emea-orion
compression:i:1
keyboardhook:i:2
audiomode:i:2
redirectdrives:i:0
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:0
displayconnectionbar:i:1
alternate shell:s:
shell working directory:s:
disable wallpaper:i:1
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:1
bitmapcachepersistenable:i:1
winposstr:s:0,3,0,0,800,600
redirectclipboard:i:1
redirectposdevices:i:0
drivestoredirect:s:
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
allow desktop composition:i:0
allow font smoothing:i:0
disable cursor setting:i:0
gatewayhostname:s:
gatewayusagemethod:i:0
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0';

header("Content-Disposition: attachment; filename=filename.rdp");
header("Content-Type: application/rdp");
print $file;
exit();

I've used this technique before and it has worked well. The user will click the link, be prompted to save or open, and if they click open Remote Desktop will launch with the settings specified.


Example for .NET in particular ASP.MVC

public FileResult RDP() {
    MemoryStream memoryStream = new MemoryStream();
    TextWriter tw = new StreamWriter(memoryStream);
    tw.WriteLine("screen mode id:i:2");
    tw.WriteLine("use multimon:i:0");
    ///The rest of the file
    memoryStream.Position = 0;
    return File(memoryStream, "application/rdp", "conenction.rdp");
}

May I suggest the use of a browser based RDP client? You have open source choice nowadays, from Guacamole FreeRDP-WebConnect if you have Linux servers or Myrtille for Windows. There are also commercial software, with more features (it depends on your needs) like 2X RDP client or LogMeIn.

Tags:

Web

Rdp