Generating RDP file on the fly
Asked Answered
T

2

6

I want to create a web application similar to TS Web Access, where I can create rdp files on the fly for Remote Apps configured on the server. Any idea??

Teratogenic answered 19/11, 2009 at 9:40 Comment(0)
S
2

We had to do this exact thing.

private void InvokeRDPSign(String fileName, String certificateThumbPrint)
{
    Process signingProcess = new Process();
    signingProcess.StartInfo.FileName = @"rdpsign.exe";

    String arguments = String.Format("/sha1 {0} {1}", certificateThumbPrint, fileName);
    signingProcess.StartInfo.Arguments = arguments;
    signingProcess.StartInfo.UseShellExecute = false;
    signingProcess.StartInfo.RedirectStandardOutput = true;
    signingProcess.StartInfo.WorkingDirectory = Environment.SystemDirectory;
    signingProcess.Start();

    String signingOutput = signingProcess.StandardOutput.ReadToEnd();
    signingProcess.WaitForExit();
    int exitCode = signingProcess.ExitCode;
    //TODO:  should we throw an error if the exitcode is not 0
}

Be aware that that the RDPSign.exe is different on each version of windows. You will find that an older version of the utility will ignore newer settings from the signature.

Stonecrop answered 11/3, 2011 at 7:4 Comment(1)
I had to use an elevated account for the app pool identity to make this work. As other posts have suggested, I'm probably going to move this code to a service on the machine with elevated privileges rather than permanently changing the app pool identity.Crapulous
E
1

well Having looked at a 'rdp' file this is the contents:

screen mode id:i:2
desktopwidth:i:1280
desktopheight:i:768
session bpp:i:32
winposstr:s:2,3,1430,104,2230,704
compression:i:1
keyboardhook:i:2
displayconnectionbar:i:1
disable wallpaper:i:1
disable full window drag:i:1
allow desktop composition:i:0
allow font smoothing:i:0
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s: [YOUR IP]
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:1
drivestoredirect:s:

Just create that as a string, seems straightforward.

ps I have no idea what the 'winposstr' parameter is...

Entire answered 19/11, 2009 at 9:51 Comment(10)
this is perfectly fine, but my remoteapps are digitally signed with a certificate, which adds 2 additional parameters in my rdp file: 1. signscope:s 2. signature:s How can I create values for these parameters, these are using SHA1 hash...???Teratogenic
I don't know whats going on with these certs. can't you create a valid 'remote application' RDP and then copy that sig? or is the sig different each time?Entire
Signature is same everytime, but i hv to open diff. app on diff buttons, and signature depends on the remote app program name, so i hv to change the signature on the fly. Sample rdp file content:Teratogenic
span monitors:i:1 prompt for credentials on client:i:1 remoteapplicationmode:i:1 server port:i:3389 allow font smoothing:i:1 promptcredentialonce:i:1 authentication level:i:0 gatewayusagemethod:i:2 gatewayprofileusagemethod:i:0 gatewaycredentialssource:i:0 full address:s:LUTRONTS1 alternate shell:s:||TSClient_TS2 remoteapplicationprogram:s:||TSClient_TS2 gatewayhostname:s: remoteapplicationname:s:TSClient_TS2 remoteapplicationcmdline:s:Teratogenic
signscope:s:Full Address,Server Port,GatewayHostname,GatewayUsageMethod,GatewayProfileUsageMethod,GatewayCredentialsSource,PromptCredentialOnce,Alternate Shell,RemoteApplicationProgram,RemoteApplicationMode,RemoteApplicationName,RemoteApplicationCmdLine,Authentication Level,RedirectDrives,RedirectPrinters,RedirectCOMPorts,RedirectSmartCards,RedirectPOSDevices,RedirectClipboard,DevicesToRedirect,DrivesToRedirectTeratogenic
signature:s:AQABAAEAAACVBAAAMIIEkQYJKoZIhvcNAQcCoIIEgjCCBH4CAQExCzAJBgUrDgMC GgUAMAsGCSqGSIb3DQEHAaCCAvowggL2MIIB3qADAgECAhCMel1Y/5YAjUXCeMhU Fzi8MA0GCSqGSIb3DQEBBQUAMCQxIjAgBgNVBAMTGWx1dHJvbnRzMS5nZ24ubmFn YXJyby5jb20wHhcNMDkxMTE5MDc0NTIyWhcNMTAxMTE4MDAwMDAwWjAkMSIwIAYD VQQDExlsdXRyb250czEuZ2duL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voczxLrY0J0Hly 08EALAYywbRki60brA2AKJ6Ri3ph3KUzD2aZQiV8kVZTJzqWPp20dCvL5Cl38qG6 I30ZtN1zadkgdg3vI0Ulh8IbfgNv9uQxvtGh9R55t8GRgTpexbGAx1r9ocKTSTW3 bFwds/l25ZKWrEiA1S+4r4J8QYLnoStVZcdOPBbp9z8CFfLxFoljA8pVVFqSQb51 PWV5+k2lqwBngp290Hoi6VL6HdXkA6eLYO8DqNuOJiFYTeratogenic
winposstr might be the client window position and size (top left point, bottom right point, width and height).Typecast
Yep, looks like it: tiredblogger.wordpress.com/2008/11/05/…Typecast

© 2022 - 2024 — McMap. All rights reserved.