mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
Adding the configuration capability for the Credentials page through the Windows Registry.
This commit is contained in:
@@ -12,6 +12,9 @@ namespace mRemoteNG.App.Info
|
||||
#endregion
|
||||
|
||||
#region subkey location parameters
|
||||
// Credential
|
||||
public const string CredentialSubkey = RootKey + "\\Credentials"; // Registry subkey for general credential settings
|
||||
public const string CredentialOptionsSubkey = RootKey + "\\Credentials\\Options"; // Registry subkey for credential options within the credential settings
|
||||
|
||||
// Updates
|
||||
public const string UpdateSubkey = RootKey + "\\Updates"; // Registry subkey for general update settings
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace mRemoteNG.Config.Settings.Registry
|
||||
private static readonly RegistryHive _Hive = WindowsRegistryInfo.Hive;
|
||||
|
||||
private const string __Update = WindowsRegistryInfo.UpdateSubkey;
|
||||
//private const string __Credential = WindowsRegistryInfo.CredentialSubkey;
|
||||
private const string __Credential = WindowsRegistryInfo.CredentialSubkey;
|
||||
|
||||
#region general update registry settings
|
||||
/// <summary>
|
||||
@@ -23,7 +23,6 @@ namespace mRemoteNG.Config.Settings.Registry
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is true, which allows check for updates.
|
||||
/// If the registry key is set to true, no action will be taken because the key is not needed.
|
||||
/// </remarks>
|
||||
public static bool AllowCheckForUpdates { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Update, nameof(AllowCheckForUpdates), true);
|
||||
|
||||
@@ -32,8 +31,6 @@ namespace mRemoteNG.Config.Settings.Registry
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is true, which allows check for updates automaticaly.
|
||||
/// If the registry key is set to true, no action will be taken because the key is not needed.
|
||||
/// Important: If AllowCheckForUpdates is false, the default for this value (AllowCheckForUpdatesAutomatical) is also false, manual update checks are disabled.
|
||||
/// </remarks>
|
||||
public static bool AllowCheckForUpdatesAutomatical { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Update, nameof(AllowCheckForUpdatesAutomatical), AllowCheckForUpdates);
|
||||
|
||||
@@ -42,21 +39,40 @@ namespace mRemoteNG.Config.Settings.Registry
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default value is true, enabling the manual check for updates.
|
||||
/// If the registry key is set to true, no action will be taken because the key is not needed.
|
||||
/// Important: If AllowCheckForUpdates is false, the default for this value (AllowCheckForUpdatesManual) is also false, manual update checks are disabled.
|
||||
/// </remarks>
|
||||
public static bool AllowCheckForUpdatesManual { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Update, nameof(AllowCheckForUpdatesManual), AllowCheckForUpdates);
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether a question about checking for updates is displayed at startup.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Important: If the registry entry is set to true, a popup will appear every time you start
|
||||
/// </remarks>
|
||||
public static bool AllowPromptForUpdatesPreference { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Update, nameof(AllowPromptForUpdatesPreference), AllowCheckForUpdates);
|
||||
#endregion
|
||||
|
||||
#region general credential registry settings
|
||||
/// <summary>
|
||||
/// Setting that indicates whether exporting passwords is allowed.
|
||||
/// </summary>
|
||||
public static bool AllowExportPasswords { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Credential, nameof(AllowExportPasswords), true);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Setting that indicates whether exporting usernames is allowed.
|
||||
/// </summary>
|
||||
public static bool AllowExportUsernames { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Credential, nameof(AllowExportUsernames), true);
|
||||
|
||||
/// <summary>
|
||||
/// Setting that indicates whether saving passwords is allowed.
|
||||
/// </summary>
|
||||
public static bool AllowSavePasswords { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Credential, nameof(AllowSavePasswords), true);
|
||||
|
||||
/// <summary>
|
||||
/// Setting that indicates whether saving usernames is allowed.
|
||||
/// </summary>
|
||||
public static bool AllowSaveUsernames { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Credential, nameof(AllowSaveUsernames), true);
|
||||
|
||||
/// <summary>
|
||||
/// Setting that indicates whether modifying credential settings is allowed.
|
||||
/// </summary>
|
||||
public static bool AllowModifyCredentialSettings { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Credential, nameof(AllowModifyCredentialSettings), true);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using System.Runtime.Versioning;
|
||||
using Microsoft.Win32;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Tools.WindowsRegistry;
|
||||
|
||||
namespace mRemoteNG.Config.Settings.Registry
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
/// Static utility class that provides access to and management of registry settings on the local machine.
|
||||
/// It abstracts complex registry operations and centralizes the handling of various registry keys.
|
||||
/// Benefits: Simplified code, enhances maintainability, and ensures consistency. #ReadOnly
|
||||
public sealed partial class OptRegistryCredentialsPage : WindowsRegistryAdvanced
|
||||
{
|
||||
#region option page credential registry settings
|
||||
/// <summary>
|
||||
/// Specifies the radio button is set to none, windows or custom on the credentials page.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When set to noinfo or windows, WindowsCredentials and CustomCredentials are not evaluated and disabled.
|
||||
/// </remarks>
|
||||
public WindowsRegistryKeyString UseCredentials { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the user set via API as the default username.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only avaiable if UseCredentials is set to custom!
|
||||
/// </remarks>
|
||||
public WindowsRegistryKeyString UserViaAPIDefault { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the default username.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only avaiable if UseCredentials is set to custom!
|
||||
/// </remarks>
|
||||
public WindowsRegistryKeyString DefaultUsername { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the default password.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only avaiable if UseCredentials is set to custom!
|
||||
/// </remarks>
|
||||
//public WindowsRegistryKeyString DefaultPassword { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the default domain.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only avaiable if UseCredentials is set to custom!
|
||||
/// </remarks>
|
||||
public WindowsRegistryKeyString DefaultDomain { get; }
|
||||
#endregion
|
||||
|
||||
public OptRegistryCredentialsPage()
|
||||
{
|
||||
RegistryHive hive = WindowsRegistryInfo.Hive;
|
||||
string subKey = WindowsRegistryInfo.CredentialOptionsSubkey;
|
||||
|
||||
UseCredentials = GetStringValidated(hive, subKey, nameof(UseCredentials),
|
||||
new string[] {
|
||||
"noinfo",
|
||||
"windows",
|
||||
"custom"
|
||||
}, true
|
||||
);
|
||||
|
||||
UserViaAPIDefault = GetString(hive, subKey, nameof(UserViaAPIDefault), null);
|
||||
DefaultUsername = GetString(hive, subKey, nameof(DefaultUsername), null);
|
||||
//Currently not supported, but needed for configuration...
|
||||
//DefaultPassword = GetPassword(hive, subKey, nameof(DefaultPassword));
|
||||
|
||||
DefaultDomain = GetString(hive, subKey, nameof(DefaultDomain), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,9 +52,6 @@ namespace mRemoteNG.Config.Settings.Registry
|
||||
/// <summary>
|
||||
/// Specifies the authentication password for the proxy.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Please only store encrypted passwords in the registry.
|
||||
/// </remarks>
|
||||
//public string ProxyAuthPass { get; }
|
||||
|
||||
public OptRegistryUpdatesPage()
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
using mRemoteNG.Config.Settings.Registry;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace mRemoteNG.Security
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SaveFilter
|
||||
{
|
||||
public SaveFilter(bool disableEverything = false)
|
||||
{
|
||||
if (disableEverything) return;
|
||||
SaveUsername = true;
|
||||
SavePassword = true;
|
||||
SaveUsername = CommonRegistrySettings.AllowSaveUsernames;
|
||||
SavePassword = CommonRegistrySettings.AllowSavePasswords;
|
||||
SaveDomain = true;
|
||||
SaveCredentialId = true;
|
||||
SaveInheritance = true;
|
||||
|
||||
15
mRemoteNG/UI/Forms/FrmExport.Designer.cs
generated
15
mRemoteNG/UI/Forms/FrmExport.Designer.cs
generated
@@ -1,5 +1,6 @@
|
||||
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Settings.Registry;
|
||||
using mRemoteNG.UI.Controls;
|
||||
|
||||
namespace mRemoteNG.UI.Forms
|
||||
@@ -72,27 +73,33 @@ namespace mRemoteNG.UI.Forms
|
||||
//
|
||||
this.chkUsername._mice = MrngCheckBox.MouseState.HOVER;
|
||||
this.chkUsername.AutoSize = true;
|
||||
this.chkUsername.Checked = true;
|
||||
this.chkUsername.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkUsername.Checked = CommonRegistrySettings.AllowExportUsernames;
|
||||
this.chkUsername.CheckState = CommonRegistrySettings.AllowExportUsernames ?
|
||||
System.Windows.Forms.CheckState.Checked :
|
||||
System.Windows.Forms.CheckState.Unchecked;
|
||||
this.chkUsername.Location = new System.Drawing.Point(15, 32);
|
||||
this.chkUsername.Name = "chkUsername";
|
||||
this.chkUsername.Size = new System.Drawing.Size(77, 17);
|
||||
this.chkUsername.TabIndex = 0;
|
||||
this.chkUsername.Text = "Username";
|
||||
this.chkUsername.UseVisualStyleBackColor = true;
|
||||
this.chkUsername.Enabled = CommonRegistrySettings.AllowExportUsernames;
|
||||
//
|
||||
// chkPassword
|
||||
//
|
||||
this.chkPassword._mice = MrngCheckBox.MouseState.HOVER;
|
||||
this.chkPassword.AutoSize = true;
|
||||
this.chkPassword.Checked = true;
|
||||
this.chkPassword.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkPassword.Checked = CommonRegistrySettings.AllowExportPasswords;
|
||||
this.chkPassword.CheckState = CommonRegistrySettings.AllowExportPasswords ?
|
||||
System.Windows.Forms.CheckState.Checked :
|
||||
System.Windows.Forms.CheckState.Unchecked;
|
||||
this.chkPassword.Location = new System.Drawing.Point(15, 55);
|
||||
this.chkPassword.Name = "chkPassword";
|
||||
this.chkPassword.Size = new System.Drawing.Size(75, 17);
|
||||
this.chkPassword.TabIndex = 1;
|
||||
this.chkPassword.Text = "Password";
|
||||
this.chkPassword.UseVisualStyleBackColor = true;
|
||||
this.chkPassword.Enabled = CommonRegistrySettings.AllowExportPasswords;
|
||||
//
|
||||
// chkDomain
|
||||
//
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
pnlDefaultCredentials = new System.Windows.Forms.Panel();
|
||||
pnlCredentialsSettingsPanel = new System.Windows.Forms.Panel();
|
||||
lblDefaultCredentials = new Controls.MrngLabel();
|
||||
radCredentialsWindows = new Controls.MrngRadioButton();
|
||||
tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
txtCredentialsUserViaAPI = new Controls.MrngTextBox();
|
||||
txtCredentialsUsername = new Controls.MrngTextBox();
|
||||
@@ -38,26 +41,61 @@
|
||||
lblCredentialsUsername = new Controls.MrngLabel();
|
||||
lblCredentialsPassword = new Controls.MrngLabel();
|
||||
lblCredentialsDomain = new Controls.MrngLabel();
|
||||
radCredentialsCustom = new Controls.MrngRadioButton();
|
||||
lblDefaultCredentials = new Controls.MrngLabel();
|
||||
radCredentialsNoInfo = new Controls.MrngRadioButton();
|
||||
radCredentialsWindows = new Controls.MrngRadioButton();
|
||||
radCredentialsCustom = new Controls.MrngRadioButton();
|
||||
lblCredentialsAdminInfo = new System.Windows.Forms.Label();
|
||||
lblCredentialsGeneratorHelp = new Controls.MrngLabel();
|
||||
btnCredentialsGenerator = new System.Windows.Forms.Button();
|
||||
lblCredentialsGenerator = new Controls.MrngLabel();
|
||||
txtCredentialsGeneratorPsswd = new System.Windows.Forms.TextBox();
|
||||
pnlDefaultCredentials.SuspendLayout();
|
||||
pnlCredentialsSettingsPanel.SuspendLayout();
|
||||
tableLayoutPanel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pnlDefaultCredentials
|
||||
//
|
||||
pnlDefaultCredentials.Controls.Add(tableLayoutPanel1);
|
||||
pnlDefaultCredentials.Controls.Add(radCredentialsCustom);
|
||||
pnlDefaultCredentials.Controls.Add(lblDefaultCredentials);
|
||||
pnlDefaultCredentials.Controls.Add(radCredentialsNoInfo);
|
||||
pnlDefaultCredentials.Controls.Add(radCredentialsWindows);
|
||||
pnlDefaultCredentials.Location = new System.Drawing.Point(3, 3);
|
||||
pnlDefaultCredentials.Controls.Add(pnlCredentialsSettingsPanel);
|
||||
pnlDefaultCredentials.Controls.Add(lblCredentialsAdminInfo);
|
||||
pnlDefaultCredentials.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
pnlDefaultCredentials.Location = new System.Drawing.Point(0, 0);
|
||||
pnlDefaultCredentials.Name = "pnlDefaultCredentials";
|
||||
pnlDefaultCredentials.Size = new System.Drawing.Size(604, 200);
|
||||
pnlDefaultCredentials.Size = new System.Drawing.Size(610, 416);
|
||||
pnlDefaultCredentials.TabIndex = 0;
|
||||
//
|
||||
// pnlCredentialsSettingsPanel
|
||||
//
|
||||
pnlCredentialsSettingsPanel.Controls.Add(lblDefaultCredentials);
|
||||
pnlCredentialsSettingsPanel.Controls.Add(radCredentialsWindows);
|
||||
pnlCredentialsSettingsPanel.Controls.Add(tableLayoutPanel1);
|
||||
pnlCredentialsSettingsPanel.Controls.Add(radCredentialsNoInfo);
|
||||
pnlCredentialsSettingsPanel.Controls.Add(radCredentialsCustom);
|
||||
pnlCredentialsSettingsPanel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
pnlCredentialsSettingsPanel.Location = new System.Drawing.Point(0, 30);
|
||||
pnlCredentialsSettingsPanel.Name = "pnlCredentialsSettingsPanel";
|
||||
pnlCredentialsSettingsPanel.Size = new System.Drawing.Size(610, 214);
|
||||
pnlCredentialsSettingsPanel.TabIndex = 0;
|
||||
//
|
||||
// lblDefaultCredentials
|
||||
//
|
||||
lblDefaultCredentials.AutoSize = true;
|
||||
lblDefaultCredentials.Location = new System.Drawing.Point(3, 0);
|
||||
lblDefaultCredentials.Name = "lblDefaultCredentials";
|
||||
lblDefaultCredentials.Size = new System.Drawing.Size(279, 13);
|
||||
lblDefaultCredentials.TabIndex = 0;
|
||||
lblDefaultCredentials.Text = "For empty Username, Password or Domain fields use:";
|
||||
//
|
||||
// radCredentialsWindows
|
||||
//
|
||||
radCredentialsWindows.AutoSize = true;
|
||||
radCredentialsWindows.BackColor = System.Drawing.Color.Transparent;
|
||||
radCredentialsWindows.Location = new System.Drawing.Point(6, 39);
|
||||
radCredentialsWindows.Name = "radCredentialsWindows";
|
||||
radCredentialsWindows.Size = new System.Drawing.Size(252, 17);
|
||||
radCredentialsWindows.TabIndex = 2;
|
||||
radCredentialsWindows.Text = "my current credentials (windows logon info)";
|
||||
radCredentialsWindows.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
tableLayoutPanel1.ColumnCount = 2;
|
||||
@@ -71,7 +109,7 @@
|
||||
tableLayoutPanel1.Controls.Add(lblCredentialsUsername, 0, 1);
|
||||
tableLayoutPanel1.Controls.Add(lblCredentialsPassword, 0, 2);
|
||||
tableLayoutPanel1.Controls.Add(lblCredentialsDomain, 0, 3);
|
||||
tableLayoutPanel1.Location = new System.Drawing.Point(23, 85);
|
||||
tableLayoutPanel1.Location = new System.Drawing.Point(26, 85);
|
||||
tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
tableLayoutPanel1.RowCount = 3;
|
||||
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
|
||||
@@ -113,7 +151,6 @@
|
||||
txtCredentialsPassword.Name = "txtCredentialsPassword";
|
||||
txtCredentialsPassword.Size = new System.Drawing.Size(166, 22);
|
||||
txtCredentialsPassword.TabIndex = 7;
|
||||
txtCredentialsPassword.UseSystemPasswordChar = true;
|
||||
//
|
||||
// txtCredentialsDomain
|
||||
//
|
||||
@@ -170,33 +207,12 @@
|
||||
lblCredentialsDomain.Text = "Domain:";
|
||||
lblCredentialsDomain.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// radCredentialsCustom
|
||||
//
|
||||
radCredentialsCustom.AutoSize = true;
|
||||
radCredentialsCustom.BackColor = System.Drawing.Color.Transparent;
|
||||
radCredentialsCustom.Location = new System.Drawing.Point(3, 62);
|
||||
radCredentialsCustom.Name = "radCredentialsCustom";
|
||||
radCredentialsCustom.Size = new System.Drawing.Size(98, 17);
|
||||
radCredentialsCustom.TabIndex = 3;
|
||||
radCredentialsCustom.Text = "the following:";
|
||||
radCredentialsCustom.UseVisualStyleBackColor = false;
|
||||
radCredentialsCustom.CheckedChanged += radCredentialsCustom_CheckedChanged;
|
||||
//
|
||||
// lblDefaultCredentials
|
||||
//
|
||||
lblDefaultCredentials.AutoSize = true;
|
||||
lblDefaultCredentials.Location = new System.Drawing.Point(0, 0);
|
||||
lblDefaultCredentials.Name = "lblDefaultCredentials";
|
||||
lblDefaultCredentials.Size = new System.Drawing.Size(279, 13);
|
||||
lblDefaultCredentials.TabIndex = 0;
|
||||
lblDefaultCredentials.Text = "For empty Username, Password or Domain fields use:";
|
||||
//
|
||||
// radCredentialsNoInfo
|
||||
//
|
||||
radCredentialsNoInfo.AutoSize = true;
|
||||
radCredentialsNoInfo.BackColor = System.Drawing.Color.Transparent;
|
||||
radCredentialsNoInfo.Checked = true;
|
||||
radCredentialsNoInfo.Location = new System.Drawing.Point(3, 16);
|
||||
radCredentialsNoInfo.Location = new System.Drawing.Point(6, 16);
|
||||
radCredentialsNoInfo.Name = "radCredentialsNoInfo";
|
||||
radCredentialsNoInfo.Size = new System.Drawing.Size(103, 17);
|
||||
radCredentialsNoInfo.TabIndex = 1;
|
||||
@@ -204,16 +220,58 @@
|
||||
radCredentialsNoInfo.Text = "no information";
|
||||
radCredentialsNoInfo.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// radCredentialsWindows
|
||||
// radCredentialsCustom
|
||||
//
|
||||
radCredentialsWindows.AutoSize = true;
|
||||
radCredentialsWindows.BackColor = System.Drawing.Color.Transparent;
|
||||
radCredentialsWindows.Location = new System.Drawing.Point(3, 39);
|
||||
radCredentialsWindows.Name = "radCredentialsWindows";
|
||||
radCredentialsWindows.Size = new System.Drawing.Size(252, 17);
|
||||
radCredentialsWindows.TabIndex = 2;
|
||||
radCredentialsWindows.Text = "my current credentials (windows logon info)";
|
||||
radCredentialsWindows.UseVisualStyleBackColor = false;
|
||||
radCredentialsCustom.AutoSize = true;
|
||||
radCredentialsCustom.BackColor = System.Drawing.Color.Transparent;
|
||||
radCredentialsCustom.Location = new System.Drawing.Point(6, 62);
|
||||
radCredentialsCustom.Name = "radCredentialsCustom";
|
||||
radCredentialsCustom.Size = new System.Drawing.Size(98, 17);
|
||||
radCredentialsCustom.TabIndex = 3;
|
||||
radCredentialsCustom.Text = "the following:";
|
||||
radCredentialsCustom.UseVisualStyleBackColor = false;
|
||||
radCredentialsCustom.CheckedChanged += radCredentialsCustom_CheckedChanged;
|
||||
//
|
||||
// lblCredentialsAdminInfo
|
||||
//
|
||||
lblCredentialsAdminInfo.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||
lblCredentialsAdminInfo.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
lblCredentialsAdminInfo.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
lblCredentialsAdminInfo.Location = new System.Drawing.Point(0, 0);
|
||||
lblCredentialsAdminInfo.Name = "lblCredentialsAdminInfo";
|
||||
lblCredentialsAdminInfo.Padding = new System.Windows.Forms.Padding(0, 2, 0, 0);
|
||||
lblCredentialsAdminInfo.Size = new System.Drawing.Size(610, 30);
|
||||
lblCredentialsAdminInfo.TabIndex = 0;
|
||||
lblCredentialsAdminInfo.Text = "Some settings are configured by your Administrator. Please contact your administrator for more information.";
|
||||
lblCredentialsAdminInfo.Visible = false;
|
||||
//
|
||||
// lblCredentialsGeneratorHelp
|
||||
//
|
||||
lblCredentialsGeneratorHelp.Location = new System.Drawing.Point(0, 0);
|
||||
lblCredentialsGeneratorHelp.Name = "lblCredentialsGeneratorHelp";
|
||||
lblCredentialsGeneratorHelp.Size = new System.Drawing.Size(100, 23);
|
||||
lblCredentialsGeneratorHelp.TabIndex = 0;
|
||||
//
|
||||
// btnCredentialsGenerator
|
||||
//
|
||||
btnCredentialsGenerator.Location = new System.Drawing.Point(0, 0);
|
||||
btnCredentialsGenerator.Name = "btnCredentialsGenerator";
|
||||
btnCredentialsGenerator.Size = new System.Drawing.Size(75, 23);
|
||||
btnCredentialsGenerator.TabIndex = 0;
|
||||
//
|
||||
// lblCredentialsGenerator
|
||||
//
|
||||
lblCredentialsGenerator.Location = new System.Drawing.Point(0, 0);
|
||||
lblCredentialsGenerator.Name = "lblCredentialsGenerator";
|
||||
lblCredentialsGenerator.Size = new System.Drawing.Size(100, 23);
|
||||
lblCredentialsGenerator.TabIndex = 0;
|
||||
//
|
||||
// txtCredentialsGeneratorPsswd
|
||||
//
|
||||
txtCredentialsGeneratorPsswd.Location = new System.Drawing.Point(0, 0);
|
||||
txtCredentialsGeneratorPsswd.Name = "txtCredentialsGeneratorPsswd";
|
||||
txtCredentialsGeneratorPsswd.Size = new System.Drawing.Size(100, 23);
|
||||
txtCredentialsGeneratorPsswd.TabIndex = 0;
|
||||
//
|
||||
// CredentialsPage
|
||||
//
|
||||
@@ -224,7 +282,8 @@
|
||||
Name = "CredentialsPage";
|
||||
Size = new System.Drawing.Size(610, 490);
|
||||
pnlDefaultCredentials.ResumeLayout(false);
|
||||
pnlDefaultCredentials.PerformLayout();
|
||||
pnlCredentialsSettingsPanel.ResumeLayout(false);
|
||||
pnlCredentialsSettingsPanel.PerformLayout();
|
||||
tableLayoutPanel1.ResumeLayout(false);
|
||||
tableLayoutPanel1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
@@ -245,5 +304,11 @@
|
||||
internal Controls.MrngTextBox txtCredentialsUsername;
|
||||
internal Controls.MrngLabel lblCredentialsDomain;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
internal System.Windows.Forms.Label lblCredentialsAdminInfo;
|
||||
internal System.Windows.Forms.Panel pnlCredentialsSettingsPanel;
|
||||
internal Controls.MrngLabel lblCredentialsGenerator;
|
||||
internal System.Windows.Forms.TextBox txtCredentialsGeneratorPsswd;
|
||||
internal System.Windows.Forms.Button btnCredentialsGenerator;
|
||||
internal Controls.MrngLabel lblCredentialsGeneratorHelp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,19 @@ using mRemoteNG.Properties;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Resources.Language;
|
||||
using System.Runtime.Versioning;
|
||||
using mRemoteNG.Config.Settings.Registry;
|
||||
|
||||
namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public sealed partial class CredentialsPage : OptionsPage
|
||||
{
|
||||
#region Private Fields
|
||||
private readonly OptRegistryCredentialsPage _RegistrySettings = new();
|
||||
private bool _pageEnabled = true;
|
||||
|
||||
#endregion
|
||||
|
||||
public CredentialsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -33,10 +40,13 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
lblCredentialsUsername.Text = Language.Username;
|
||||
lblCredentialsPassword.Text = Language.Password;
|
||||
lblCredentialsDomain.Text = Language.Domain;
|
||||
lblCredentialsAdminInfo.Text = Language.OptionsAdminInfo;
|
||||
}
|
||||
|
||||
public override void LoadSettings()
|
||||
{
|
||||
if (!_pageEnabled) { return; }
|
||||
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (Properties.OptionsCredentialsPage.Default.EmptyCredentials)
|
||||
{
|
||||
@@ -80,16 +90,134 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
Properties.OptionsCredentialsPage.Default.UserViaAPIDefault = txtCredentialsUserViaAPI.Text;
|
||||
}
|
||||
|
||||
public override void LoadRegistrySettings()
|
||||
{
|
||||
if (!CommonRegistrySettings.AllowModifyCredentialSettings)
|
||||
{
|
||||
DisablePage();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_RegistrySettings.UseCredentials.IsKeyPresent)
|
||||
{
|
||||
Properties.OptionsCredentialsPage.Default.EmptyCredentials = _RegistrySettings.UseCredentials.Value;
|
||||
|
||||
switch (Properties.OptionsCredentialsPage.Default.EmptyCredentials)
|
||||
{
|
||||
case "noinfo":
|
||||
DisableControl(radCredentialsWindows);
|
||||
DisableControl(radCredentialsCustom);
|
||||
break;
|
||||
case "windows":
|
||||
DisableControl(radCredentialsNoInfo);
|
||||
DisableControl(radCredentialsCustom);
|
||||
break;
|
||||
case "custom":
|
||||
DisableControl(radCredentialsNoInfo);
|
||||
DisableControl(radCredentialsWindows);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_RegistrySettings.UseCredentials.Value != "custom") { return; }
|
||||
|
||||
|
||||
if (!CommonRegistrySettings.AllowSaveUsernames)
|
||||
{
|
||||
Properties.OptionsCredentialsPage.Default.DefaultUsername = "";
|
||||
DisableControl(txtCredentialsUsername);
|
||||
}
|
||||
else if (_RegistrySettings.DefaultUsername.IsKeyPresent)
|
||||
{
|
||||
Properties.OptionsCredentialsPage.Default.DefaultUsername = _RegistrySettings.DefaultUsername.Value;
|
||||
DisableControl(txtCredentialsUsername);
|
||||
}
|
||||
|
||||
if (!CommonRegistrySettings.AllowSavePasswords)
|
||||
{
|
||||
Properties.OptionsCredentialsPage.Default.DefaultPassword = "";
|
||||
DisableControl(txtCredentialsPassword);
|
||||
}
|
||||
//else if (_RegistrySettings.DefaultPassword.IsKeyPresent)
|
||||
//{
|
||||
// Properties.OptionsCredentialsPage.Default.DefaultPassword = _RegistrySettings.DefaultPassword.Value;
|
||||
// DisableControl(txtCredentialsPassword);
|
||||
//}
|
||||
|
||||
if (_RegistrySettings.DefaultDomain.IsKeyPresent)
|
||||
{
|
||||
Properties.OptionsCredentialsPage.Default.DefaultDomain = _RegistrySettings.DefaultDomain.Value;
|
||||
DisableControl(txtCredentialsDomain);
|
||||
}
|
||||
|
||||
if (!CommonRegistrySettings.AllowSaveUsernames)
|
||||
{
|
||||
Properties.OptionsCredentialsPage.Default.UserViaAPIDefault = "";
|
||||
DisableControl(txtCredentialsUserViaAPI);
|
||||
}
|
||||
else if (_RegistrySettings.UserViaAPIDefault.IsKeyPresent)
|
||||
{
|
||||
Properties.OptionsCredentialsPage.Default.UserViaAPIDefault = _RegistrySettings.UserViaAPIDefault.Value;
|
||||
DisableControl(txtCredentialsUserViaAPI);
|
||||
}
|
||||
|
||||
lblCredentialsAdminInfo.Visible = ShowAdministratorInfo();
|
||||
}
|
||||
|
||||
public override bool ShowAdministratorInfo()
|
||||
{
|
||||
return !CommonRegistrySettings.AllowModifyCredentialSettings
|
||||
|| !CommonRegistrySettings.AllowExportPasswords
|
||||
|| !CommonRegistrySettings.AllowExportUsernames
|
||||
|| !CommonRegistrySettings.AllowSavePasswords
|
||||
|| !CommonRegistrySettings.AllowSaveUsernames
|
||||
|| _RegistrySettings.DefaultUsername.IsKeyPresent
|
||||
//|| _RegistrySettings.DefaultPassword.IsKeyPresent
|
||||
|| _RegistrySettings.DefaultDomain.IsKeyPresent
|
||||
|| _RegistrySettings.UserViaAPIDefault.IsKeyPresent;
|
||||
}
|
||||
|
||||
private void radCredentialsCustom_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
lblCredentialsUsername.Enabled = radCredentialsCustom.Checked;
|
||||
lblCredentialsPassword.Enabled = radCredentialsCustom.Checked;
|
||||
lblCredentialsDomain.Enabled = radCredentialsCustom.Checked;
|
||||
txtCredentialsUsername.Enabled = radCredentialsCustom.Checked;
|
||||
txtCredentialsPassword.Enabled = radCredentialsCustom.Checked;
|
||||
txtCredentialsDomain.Enabled = radCredentialsCustom.Checked;
|
||||
txtCredentialsUserViaAPI.Enabled = radCredentialsCustom.Checked;
|
||||
lblCredentialsUserViaAPI.Enabled = radCredentialsCustom.Checked;
|
||||
if (!_RegistrySettings.DefaultUsername.IsKeyPresent && CommonRegistrySettings.AllowSaveUsernames)
|
||||
{
|
||||
lblCredentialsUsername.Enabled = radCredentialsCustom.Checked;
|
||||
txtCredentialsUsername.Enabled = radCredentialsCustom.Checked;
|
||||
}
|
||||
|
||||
if (/*!_RegistrySettings.DefaultPassword.IsKeyPresent &&*/ CommonRegistrySettings.AllowSavePasswords)
|
||||
{
|
||||
lblCredentialsPassword.Enabled = radCredentialsCustom.Checked;
|
||||
txtCredentialsPassword.Enabled = radCredentialsCustom.Checked;
|
||||
}
|
||||
|
||||
if (!_RegistrySettings.DefaultDomain.IsKeyPresent)
|
||||
{
|
||||
lblCredentialsDomain.Enabled = radCredentialsCustom.Checked;
|
||||
txtCredentialsDomain.Enabled = radCredentialsCustom.Checked;
|
||||
}
|
||||
|
||||
if (!_RegistrySettings.UserViaAPIDefault.IsKeyPresent)
|
||||
{
|
||||
lblCredentialsUserViaAPI.Enabled = radCredentialsCustom.Checked;
|
||||
txtCredentialsUserViaAPI.Enabled = radCredentialsCustom.Checked;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DisablePage()
|
||||
{
|
||||
Properties.OptionsCredentialsPage.Default.EmptyCredentials = "noinfo";
|
||||
//radCredentialsNoInfo.Enabled = false;
|
||||
radCredentialsWindows.Enabled = false;
|
||||
radCredentialsCustom.Enabled = false;
|
||||
|
||||
txtCredentialsUsername.Enabled = false;
|
||||
txtCredentialsPassword.Enabled = false;
|
||||
txtCredentialsDomain.Enabled = false;
|
||||
txtCredentialsUserViaAPI.Enabled = false;
|
||||
|
||||
lblCredentialsAdminInfo.Visible = true;
|
||||
_pageEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user