Exemplo n.º 1
0
        private string ValidateProfileName()
        {
            _profileNameTextBox.Text = _profileNameTextBox.Text.Trim();
            if (string.IsNullOrEmpty(_profileNameTextBox.Text))
            {
                return("请输入配置文件名");
            }
            if (LogonCredentials.IsCustomProfile(ProfileName))
            {
                return("'{0}' 是保留的配置文件名称".InvariantFormat("Custom"));
            }
            CredentialsStore credentialsProfiles = Program.CredentialsProfiles;
            string           text = "Global";

            if (ProfileScope == ProfileScope.File)
            {
                credentialsProfiles = _file.CredentialsProfiles;
                text = _file.Text;
            }
            if (credentialsProfiles.Contains(ProfileName))
            {
                DialogResult dialogResult = FormTools.YesNoDialog(ProfileName + " already exists in " + text + Environment.NewLine + "Update?", MessageBoxDefaultButton.Button2);
                if (dialogResult != DialogResult.Yes)
                {
                    return("配置文件存在");
                }
            }
            return(null);
        }
Exemplo n.º 2
0
 private void ResolveAndFixCredentials(LogonCredentials logonCredentials)
 {
     if (logonCredentials != null && !ResolveCredentials(logonCredentials))
     {
         logonCredentials.ProfileName.Reset();
     }
 }
Exemplo n.º 3
0
 public void CreateControls(bool inputServerName, LogonCredentials logonCredentials, ConnectionSettings connectionSettings, FileGroup fileGroup)
 {
     QuickConnectTabPage = new QuickConnectTabPage(this, logonCredentials);
     QuickConnectTabPage.CreateControls(inputServerName, fileGroup);
     AddTabPage(QuickConnectTabPage);
     connectionSettings.InheritSettingsType.Mode = InheritanceMode.Disabled;
     AddTabPage(connectionSettings.CreateTabPage(this));
     InitButtons();
 }
Exemplo n.º 4
0
 public void InitFromCredentials(ILogonCredentials credentials)
 {
     if (ProfileComboBox != null)
     {
         _usingCustomCredentials       = LogonCredentials.IsCustomProfile(credentials.ProfileName);
         ProfileComboBox.SelectedIndex = ProfileComboBox.FindItem(LogonCredentials.ConstructQualifiedName(credentials));
     }
     UserNameTextBox.Text = credentials.UserName;
     InitPassword(credentials.Password);
     DomainTextBox.Text = credentials.Domain;
 }
Exemplo n.º 5
0
 public static void ThrottledConnectAs(IEnumerable <ServerBase> servers, LogonCredentials logonCredentials, ConnectionSettings connectionSettings, Action <ServerBase> postConnectAction)
 {
     ThrottledOperation(servers, new RdpClient.ConnectionState[2]
     {
         RdpClient.ConnectionState.Connected,
         RdpClient.ConnectionState.Disconnected
     }, delegate(ServerBase server)
     {
         server.ConnectAs(logonCredentials, connectionSettings);
         postConnectAction(server);
     }, 125);
 }
Exemplo n.º 6
0
 public void ReadXml(XmlNode xmlNode, ProfileScope scope, RdcTreeNode node, ICollection <string> errors)
 {
     foreach (XmlNode childNode in xmlNode.ChildNodes)
     {
         LogonCredentials logonCredentials = new LogonCredentials("", "credentialsProfile");
         logonCredentials.ReadXml(childNode, node, errors);
         ILogonCredentials  logonCredentials2  = logonCredentials;
         CredentialsProfile credentialsProfile = new CredentialsProfile(logonCredentials2.ProfileName, scope, logonCredentials2.UserName, logonCredentials2.Password, logonCredentials2.Domain);
         this[logonCredentials2.ProfileName] = credentialsProfile;
         Encryption.DeferDecryption(credentialsProfile, node, credentialsProfile.QualifiedName);
     }
 }
Exemplo n.º 7
0
 private void CheckCredentials(RdcTreeNode node, LogonCredentials credentials, string name, Dictionary <string, List <string> > missingProfiles)
 {
     if (credentials != null && credentials.InheritSettingsType.Mode != 0 && !node.ResolveCredentials(credentials))
     {
         string key = LogonCredentials.ConstructQualifiedName(credentials);
         if (!missingProfiles.TryGetValue(key, out List <string> value))
         {
             List <string> list2 = missingProfiles[key] = new List <string>();
             value = list2;
         }
         value.Add($"{node.FullPath}.{name}");
     }
 }
Exemplo n.º 8
0
 public void WriteXml(XmlTextWriter tw, RdcTreeNode node)
 {
     tw.WriteStartElement("credentialsProfiles");
     foreach (CredentialsProfile profile in Profiles)
     {
         LogonCredentials logonCredentials = new LogonCredentials("", "credentialsProfile");
         logonCredentials.InheritSettingsType.Mode = InheritanceMode.None;
         logonCredentials.ProfileName.Value        = ((ILogonCredentials)profile).ProfileName;
         LogonCredentials logonCredentials2 = logonCredentials;
         logonCredentials2.UserName.Value = ((ILogonCredentials)profile).UserName;
         logonCredentials2.Password.Copy(((ILogonCredentials)profile).Password);
         logonCredentials2.Domain.Value = ((ILogonCredentials)profile).Domain;
         logonCredentials2.WriteXml(tw, node);
     }
     tw.WriteEndElement();
 }
Exemplo n.º 9
0
 private void OnProfileChanged(object sender, EventArgs e)
 {
     if (_inheritSettings == null || !_inheritSettings.FromParentCheck.Checked)
     {
         ILogonCredentials selectedValue = ProfileComboBox.SelectedValue;
         _usingCustomCredentials = LogonCredentials.IsCustomProfile(selectedValue.ProfileName);
         EnableDisableControls(enable: true);
         if (_usingCustomCredentials)
         {
             UserNameTextBox.Text = Environment.UserName;
             InitPassword(null);
             DomainTextBox.Text = Environment.UserDomainName;
         }
         else
         {
             UserNameTextBox.Text = selectedValue.UserName;
             InitPassword(selectedValue.Password);
             DomainTextBox.Text = selectedValue.Domain;
         }
     }
 }
Exemplo n.º 10
0
 protected virtual void InitSettings()
 {
     LogonCredentials      = new LogonCredentials();
     ConnectionSettings    = new ConnectionSettings();
     GatewaySettings       = new GatewaySettings();
     RemoteDesktopSettings = new RemoteDesktopSettings();
     LocalResourceSettings = new LocalResourcesSettings();
     SecuritySettings      = new SecuritySettings();
     if (Properties != null)
     {
         AllSettingsGroups.Add(Properties);
     }
     AllSettingsGroups.AddRange(new SettingsGroup[7]
     {
         LogonCredentials,
         ConnectionSettings,
         GatewaySettings,
         RemoteDesktopSettings,
         LocalResourceSettings,
         DisplaySettings,
         SecuritySettings
     });
 }
Exemplo n.º 11
0
        internal bool ResolveCredentials(LogonCredentials logonCredentials)
        {
            if (logonCredentials.ProfileName.Scope == ProfileScope.Local)
            {
                if (!LogonCredentials.IsCustomProfile(logonCredentials.ProfileName.Value))
                {
                    logonCredentials.ProfileName.Value = "Custom";
                }
                return(true);
            }
            CredentialsProfile credentialsProfile = LookupCredentialsProfile(logonCredentials);

            if (credentialsProfile != null)
            {
                logonCredentials.UserName.Value = credentialsProfile.UserName;
                logonCredentials.Domain.Value   = credentialsProfile.Domain;
                if (credentialsProfile.IsDecrypted)
                {
                    logonCredentials.Password.SetPlainText(credentialsProfile.Password.Value);
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 12
0
 public abstract void ConnectAs(LogonCredentials logonSettings, ConnectionSettings connectionSettings);
Exemplo n.º 13
0
 public static void ThrottledConnectAs(IEnumerable <ServerBase> servers, LogonCredentials logonCredentials, ConnectionSettings connectionSettings)
 {
     ThrottledConnectAs(servers, logonCredentials, connectionSettings, delegate
     {
     });
 }
Exemplo n.º 14
0
 public override void ConnectAs(LogonCredentials logonSettings, ConnectionSettings connectionsettings)
 {
     _server.ConnectAs(logonSettings, connectionsettings);
 }