示例#1
0
        public bool DoChangePassword(Window owner)
        {
            bool _result = false;

            try
            {
                this.LastError = string.Empty;

                if (ChangePasswordDialog.Show(owner))
                {
                    Mouse.SetCursor(System.Windows.Input.Cursors.Wait);
                    this.Connect();
                    try
                    {
                        // if connected
                        if (this.IsConnected)
                        {
                            m_TC.Read();

                            string _response;
                            // execute passwd
                            Loggy.Logger.Debug("Telnet Sent passwd");
                            m_TC.WriteLine("passwd");
                            _response = m_TC.Read().Replace("passwd", "");
                            if (_response.Contains("Changing password"))
                            {
                                m_TC.WriteLine(ChangePasswordDialog.Password);
                                _response = m_TC.Read();
                                if (_response.Contains("Retype password"))
                                {
                                    m_TC.WriteLine(ChangePasswordDialog.Password);
                                    _response = m_TC.Read();
                                    _result   = _response.Contains("changed");
                                    Loggy.Logger.Debug("Telnet Password changed");
                                    //if (!_result)
                                    //{
                                    //    this.LastError = _response.Replace("\r", " ").Replace("\n", " ");
                                    //}
                                }
                            }
                        }
                    }
                    finally
                    {
                        this.Disconnect();
                    }
                }

                if (_result)
                {
                    FileManager.Configuration.Options.TelnetOptions.TelnetPass = ChangePasswordDialog.Password;
                    FileManager.Configuration.Options.SSHOptions.SSHPass       = ChangePasswordDialog.Password;
                }
            }
            finally
            {
                Mouse.SetCursor(System.Windows.Input.Cursors.Arrow);
            }

            return(_result);
        }