12. November 2013 21:16
/
Martin Poisel
/
Comments (1)
Our company's IS has database with customer computers and their fqdn addresses. We used to have binnary .rdp files stored in sql database along with other informations. It was very sticky and lengthy to insert new records and upload new .rdp files and everybody was lazy to do that.
So I decided to write some solution to dynamicly generate .rdp files from my IS. Here is simple handler.
<%@ WebHandler Language="C#" Class="RDP" %>
using System;
using System.Web;
public class RDP : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.AddHeader("Content-Type", "application/rdp");
context.Response.AddHeader("Content-Disposition", "attachment; filename=map.rdp");
context.Response.Write("screen mode id:i:2\n");
context.Response.Write("use multimon:i:0\n");
context.Response.Write("desktopwidth:i:1920\n");
context.Response.Write("desktopheight:i:1200\n");
context.Response.Write("session bpp:i:32\n");
context.Response.Write("winposstr:s:0,1,0,0,800,600\n");
context.Response.Write("compression:i:1\n");
context.Response.Write("keyboardhook:i:2\n");
context.Response.Write("audiocapturemode:i:0\n");
context.Response.Write("videoplaybackmode:i:1\n");
context.Response.Write("connection type:i:2\n");
context.Response.Write("displayconnectionbar:i:1\n");
context.Response.Write("disable wallpaper:i:1\n");
context.Response.Write("allow font smoothing:i:0\n");
context.Response.Write("allow desktop composition:i:0\n");
context.Response.Write("disable full window drag:i:1\n");
context.Response.Write("disable menu anims:i:1\n");
context.Response.Write("disable themes:i:0\n");
context.Response.Write("disable cursor setting:i:0\n");
context.Response.Write("bitmapcachepersistenable:i:1\n");
context.Response.Write("full address:s:" + context.Request.QueryString["RDPAddress"] + "\n");
context.Response.Write("audiomode:i:0\n");
context.Response.Write("redirectprinters:i:1\n");
context.Response.Write("redirectcomports:i:0\n");
context.Response.Write("redirectsmartcards:i:1\n");
context.Response.Write("redirectclipboard:i:1\n");
context.Response.Write("redirectposdevices:i:0\n");
context.Response.Write("redirectdirectx:i:1\n");
context.Response.Write("autoreconnection enabled:i:1\n");
context.Response.Write("prompt for credentials:i:0\n");
context.Response.Write("negotiate security layer:i:1\n");
context.Response.Write("remoteapplicationmode:i:0\n");
context.Response.Write("alternate shell:s:\n");
context.Response.Write("shell working directory:s:\n");
context.Response.Write("gatewayhostname:s:" + context.Request.QueryString["RDPGateway"] + "\n");
context.Response.Write("gatewayusagemethod:i:2\n");
context.Response.Write("gatewaycredentialssource:i:0\n");
context.Response.Write("gatewayprofileusagemethod:i:1\n");
context.Response.Write("promptcredentialonce:i:1\n");
context.Response.Write("use redirection server name:i:0\n");
context.Response.Write("drivestoredirect:s:\n");
context.Response.Write("networkautodetect:i:1\n");
context.Response.Write("bandwidthautodetect:i:1\n");
context.Response.Write("enableworkspacereconnect:i:0\n");
context.Response.Write("rdgiskdcproxy:i:0\n");
context.Response.Write("kdcproxyname:s:\n");
context.Response.End();
}
public bool IsReusable {
get {
return false;
}
}
}
RDP.ashx (3.30 kb)
ed54380e-2124-426c-9ed4-a75c40e0b913|2|3.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04