Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6093575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:34:33+00:00 2026-05-23T12:34:33+00:00

I created ASP.Net page which create .rdp file and then open it as below:

  • 0

I created ASP.Net page which create .rdp file and then open it as below:

 public static void Rdc(String server, String UserName, String password, out String filename)
{
    String ss= Environment.UserName;
    filename = @"c:\temp.rdp";
    if(File.Exists(filename))
        File.Delete(filename);
    if (!File.Exists(filename))
    {
        using (FileStream fs = File.Create(filename))

        using (StreamWriter sw = new StreamWriter(fs))
        {
            sw.WriteLine("screen mode id:i:2");
            sw.WriteLine("desktopwidth:i:1440");
            sw.WriteLine("desktopheight:i:900");
            sw.WriteLine("session bpp:i:32");
            sw.WriteLine("winposstr:s:0,1,4,12,1440,864");
            sw.WriteLine("compression:i:1");
            sw.WriteLine("keyboardhook:i:2");
            sw.WriteLine("administrative session:i:1");
            sw.WriteLine("displayconnectionbar:i:1");
            sw.WriteLine("disable wallpaper:i:1");
            sw.WriteLine("disable full window drag:i:1");
            sw.WriteLine("allow desktop composition:i:0");
            sw.WriteLine("allow font smoothing:i:0");
            sw.WriteLine("disable menu anims:i:1");
            sw.WriteLine("disable themes:i:0");
            sw.WriteLine("disable cursor setting:i:0");
            sw.WriteLine("bitmapcachepersistenable:i:1");
            sw.WriteLine("full address:s:" + server);
            sw.WriteLine("username:s:" + UserName);
            sw.WriteLine("password 51:b:" + rdpEncrypt(password));                
            sw.WriteLine("audiomode:i:0");
            sw.WriteLine("redirectprinters:i:1");
            sw.WriteLine("redirectcomports:i:0");
            sw.WriteLine("redirectsmartcards:i:1");
            sw.WriteLine("redirectclipboard:i:1");
            sw.WriteLine("redirectposdevices:i:0");
            sw.WriteLine("autoreconnection enabled:i:1");
            sw.WriteLine("authentication level:i:0");
            sw.WriteLine("prompt for credentials:i:0");
            sw.WriteLine("negotiate security layer:i:1");
            sw.WriteLine("remoteapplicationmode:i:0");
        }

    }
}

and then call it from the web page :

  public static Boolean openrdp(string path)
{
    // Get the physical Path of the file 
    string filepath = path;

    // Create New instance of FileInfo class to get the properties of the file being downloaded 
    FileInfo file = new FileInfo(filepath);

    // Checking if file exists 
    if (file.Exists)
    {
        // Clear the content of the response 
        HttpContext.Current.Response.ClearContent();

        // LINE1: Add the file name and attachment, which will force the open/cance/save dialog to show, to the header 
        //Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); 
        HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=" + file.Name);


        // Add the file size into the response header 
        HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());

        // Set the ContentType 
        HttpContext.Current.Response.ContentType = ReturnExtension(file.Extension.ToLower());

        // Write the file into the response (TransmitFile is for ASP.NET 2.0. In ASP.NET 1.1 you have to use WriteFile instead) 
        HttpContext.Current.Response.TransmitFile(file.FullName);

        // End the response 
        HttpContext.Current.Response.End();

        return true;
    }
    else
        return false;
}
public static string ReturnExtension(string fileExtension)
{
    switch (fileExtension)
    {
        case ".htm":
        case ".html":
        case ".log":
            return "text/HTML";
        case ".txt":
            return "text/plain";
        case ".docx":
            return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
        case ".doc":
            return "application/msword";
        case ".tiff":
        case ".tif":
            return "image/tiff";
        case ".asf":
            return "video/x-ms-asf";
        case ".avi":
            return "video/avi";
        case ".zip":
            return "application/zip";
        case ".xls":
        case ".csv":
            return "application/vnd.ms-excel";
        case ".gif":
            return "image/gif";
        case ".jpg":
        case "jpeg":
            return "image/jpeg";
        case ".bmp":
            return "image/bmp";
        case ".wav":
            return "audio/wav";
        case ".mp3":
            return "audio/mpeg3";
        case ".mpg":
        case "mpeg":
            return "video/mpeg";
        case ".rtf":
            return "application/rtf";
        case ".asp":
            return "text/asp";
        case ".pdf":
            return "application/pdf";
        case ".fdf":
            return "application/vnd.fdf";
        case ".ppt":
            return "application/mspowerpoint";
        case ".dwg":
            return "image/vnd.dwg";
        case ".msg":
            return "application/msoutlook";
        case ".xml":
        case ".sdxl":
            return "application/xml";
        case ".xdp":
            return "application/vnd.adobe.xdp+xml";
        case ".rdp":
            return "application/x-rdp";
        default:
            return "application/octet-stream";
    }

}

the problem id that remote connection opened but with user name only without password.
Note: i encypt the password in .rdp file

any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:34:33+00:00Added an answer on May 23, 2026 at 12:34 pm

    I’m guessing that the passwords in the RDP file are encrypted by the user who saves it (i.e. the web application pool user). And decrypted on the fly when opened.

    So if another user tries to open it (i.e. the user downloading the file), then the encrypted password cannot be read.


    EDIT

    Looking at this article about generating RDP files

    It looks as though the CryptProtectData function is used to encrypt the information. According to MSDN about CyptProtectData this can only be decrypted by the person with the same user credentials and typically on the same computer the encryption was performed. The msdn article does mention the use of roaming profiles to decrypt on other computers.

    So perhaps you can authenticate your ASP.net with Active Directory and impersonate the user whilst doing the encryption and then they might be able to decrypt on their local machine.

    Another thing I have seen is that terminal services on “Juniper” launches what appears to be remote desktop and logs you in automatically. So perhaps researching this may give you another option. You may be able to get more detail about Juniper on serverfault.com

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ASP.Net MVC along with Jquery to create a page which contains
I need to create an ASP page (classic, not ASP.NET) which runs remote shell
I have a Login Page which is created in asp.net now when i successfully
I need to create an asp.net web page which shows the client system (PC)
I've been trying to create a C# ASP.NET page which sits on a Windows
I've created a asp.net page which execute a very long sp (about 1 hour
I have created a web page (ASP.NET) that includes a stylesheet to mimic Dynamics
I created a new ASP.NET MVC application. The home page looks like this: I
Just starting out in asp.net. Have just created a login.aspx page in my site
I create a asp.net page and test the code in debug mode step by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.