Ejemplo n.º 1
0
        /// <inheritdoc />
        protected override void ProcessRecord()
        {
            var networkCredential = Credential.GetNetworkCredential();
            var userName          = networkCredential.UserName;
            var userDomain        = networkCredential.Domain;
            var userPassword      = networkCredential.Password;

            var rdp = new RDP();

            rdp.Connect(ComputerName, userDomain, userName, userPassword);

            if (rdp.Connected)
            {
                var sessionState = new RdpSessionStateInfo(rdp)
                {
                    ComputerName = ComputerName,
                    UserName     = userDomain.Length > 0? $"{userDomain.Split('.')[0]}\\{userName}": userName
                };
                WriteObject(sessionState);
            }
            else
            {
                WriteError(
                    new ErrorRecord(
                        new InvalidOperationException($"Failed to connect to {ComputerName}"),
                        null,
                        ErrorCategory.ConnectionError, ComputerName));
            }
        }
Ejemplo n.º 2
0
 /**
  * Connect to FreeRDP server, start thread
  */
 public void Connect(string hostname, int port, string username, string domain, string password)
 {
     rdp.SetUpdateInterface(this);
     rdp.SetPrimaryUpdateInterface(this);
     rdp.Connect(hostname, port, username, domain, password);
     procRunning = true;
     thread.Start();
 }
Ejemplo n.º 3
0
        /**
         * Connect to FreeRDP server, start thread
         */
        public void Connect(string hostname, string domain, string username, string password, int port = 3389, ConnectionSettings settings = null)
        {
            rdp.SetUpdateInterface(this);
            rdp.SetPrimaryUpdateInterface(this);

            this.settings = settings;

            rdp.Connect(hostname, domain, username, password, port, settings);

            procRunning = true;
            thread.Start();
        }
Ejemplo n.º 4
0
        /**
         * Connect to FreeRDP server, start thread
         */
        public void Connect(ConnectionSettings settings)
        {
            rdp.SetUpdateInterface(this);
            rdp.SetPrimaryUpdateInterface(this);

            this.settings = settings;

            rdp.Connect(settings.hostname, settings.port,
                        settings.username, settings.domain, settings.password);

            procRunning = true;
            thread.Start();
        }
Ejemplo n.º 5
0
        private void newConnectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (ConnectionDialog dialog = new ConnectionDialog())
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var settings = dialog.GetConnectionSettings();

                    _rdp.Connect(settings.hostname, settings.domain, settings.username, settings.password, settings.port,
                                 new FreeRDP.Core.ConnectionSettings()
                    {
                        DesktopWidth = 1920, DesktopHeight = 1080
                    });

                    //send enter to dismiss legal notice message
                    Thread.Sleep(2000);
                    _rdp.SendInputKeyboardEvent(KeyboardFlags.KBD_FLAGS_DOWN, 28);
                    Thread.Sleep(200);
                    _rdp.SendInputKeyboardEvent(KeyboardFlags.KBD_FLAGS_RELEASE, 28);

                    UpdateStatusLabel();
                }
            }
        }