Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/mRemoteNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjacko873 <jacko873@users.noreply.github.com>2022-01-28 15:50:13 +0300
committerjacko873 <jacko873@users.noreply.github.com>2022-01-28 15:50:13 +0300
commiteb859e5edec78ab92eadc2df8eabca6cdf3edf8a (patch)
tree4adba2d381b6bc2ebf84b38d5d3b6831e86847b1
parentf9d4e3152b1d930d5abb0417e151929c11b4d7c8 (diff)
External Connectors, Default Options updated
Updated options form to fix UI bug where domain was pushout of range, Added saving of default User API ID adjusted RDP and SHH to check for default User API ID, also adjusted code here for consistancey
-rw-r--r--mRemoteNG/Connection/Protocol/PuttyBase.cs42
-rw-r--r--mRemoteNG/Connection/Protocol/RDP/RdpProtocol6.cs40
-rw-r--r--mRemoteNG/Properties/Settings.Designer.cs12
-rw-r--r--mRemoteNG/Properties/Settings.settings3
-rw-r--r--mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.Designer.cs4
-rw-r--r--mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.cs4
6 files changed, 72 insertions, 33 deletions
diff --git a/mRemoteNG/Connection/Protocol/PuttyBase.cs b/mRemoteNG/Connection/Protocol/PuttyBase.cs
index a3240f62..e2577d64 100644
--- a/mRemoteNG/Connection/Protocol/PuttyBase.cs
+++ b/mRemoteNG/Connection/Protocol/PuttyBase.cs
@@ -79,13 +79,16 @@ namespace mRemoteNG.Connection.Protocol
if (PuttyProtocol == Putty_Protocol.ssh)
{
- var username = "";
- var password = "";
+
+ var username = InterfaceControl.Info?.Username ?? "";
+ var password = InterfaceControl.Info?.Password ?? "";
+ var domain = InterfaceControl.Info?.Domain ?? "";
+ var UserViaAPI = InterfaceControl.Info?.UserViaAPI ?? "";
+
// access secret server api if necessary
- if (!string.IsNullOrEmpty(InterfaceControl.Info?.UserViaAPI))
- {
- var domain = ""; // dummy
+ if (!string.IsNullOrEmpty(UserViaAPI)) {
+
try
{
ExternalConnectors.TSS.SecretServerInterface.FetchSecretFromServer("SSAPI:" + InterfaceControl.Info?.UserViaAPI, out username, out password, out domain);
@@ -95,29 +98,34 @@ namespace mRemoteNG.Connection.Protocol
Event_ErrorOccured(this, "Secret Server Interface Error: " + ex.Message, 0);
}
}
- if (!string.IsNullOrEmpty(InterfaceControl.Info?.Username))
- {
- username = InterfaceControl.Info.Username;
- }
- else
+
+ if (string.IsNullOrEmpty(username))
{
- // ReSharper disable once SwitchStatementMissingSomeCases
switch (Settings.Default.EmptyCredentials)
{
case "windows":
username = Environment.UserName;
break;
- case "custom":
+ case "custom" when !string.IsNullOrEmpty(Settings.Default.DefaultUsername):
username = Settings.Default.DefaultUsername;
break;
+ case "custom":
+ try
+ {
+ ExternalConnectors.TSS.SecretServerInterface.FetchSecretFromServer(
+ "SSAPI:" + Settings.Default.UserViaAPDefault, out username, out password,
+ out domain);
+ }
+ catch (Exception ex)
+ {
+ Event_ErrorOccured(this, "Secret Server Interface Error: " + ex.Message, 0);
+ }
+ break;
}
}
+
- if (!string.IsNullOrEmpty(InterfaceControl.Info?.Password))
- {
- password = InterfaceControl.Info.Password;
- }
- else
+ if (string.IsNullOrEmpty(password))
{
if (Settings.Default.EmptyCredentials == "custom")
{
diff --git a/mRemoteNG/Connection/Protocol/RDP/RdpProtocol6.cs b/mRemoteNG/Connection/Protocol/RDP/RdpProtocol6.cs
index 9daf084d..138732b4 100644
--- a/mRemoteNG/Connection/Protocol/RDP/RdpProtocol6.cs
+++ b/mRemoteNG/Connection/Protocol/RDP/RdpProtocol6.cs
@@ -463,9 +463,10 @@ namespace mRemoteNG.Connection.Protocol.RDP
var userName = connectionInfo?.Username ?? "";
var password = connectionInfo?.Password ?? "";
var domain = connectionInfo?.Domain ?? "";
+ var UserViaAPI = connectionInfo?.UserViaAPI ?? "";
// access secret server api if necessary
- if (!string.IsNullOrEmpty(connectionInfo?.UserViaAPI))
+ if (!string.IsNullOrEmpty(UserViaAPI))
{
try
{
@@ -480,13 +481,26 @@ namespace mRemoteNG.Connection.Protocol.RDP
if (string.IsNullOrEmpty(userName))
{
- if (Settings.Default.EmptyCredentials == "windows")
+ switch (Settings.Default.EmptyCredentials)
{
- _rdpClient.UserName = Environment.UserName;
- }
- else if (Settings.Default.EmptyCredentials == "custom")
- {
- _rdpClient.UserName = Settings.Default.DefaultUsername;
+ case "windows":
+ _rdpClient.UserName = Environment.UserName;
+ break;
+ case "custom" when !string.IsNullOrEmpty(Settings.Default.DefaultUsername):
+ _rdpClient.UserName = Settings.Default.DefaultUsername;
+ break;
+ case "custom":
+ try
+ {
+ ExternalConnectors.TSS.SecretServerInterface.FetchSecretFromServer("SSAPI:" + Settings.Default.UserViaAPDefault, out userName, out password, out domain);
+ _rdpClient.UserName = userName;
+ }
+ catch (Exception ex)
+ {
+ Event_ErrorOccured(this, "Secret Server Interface Error: " + ex.Message, 0);
+ }
+
+ break;
}
}
else
@@ -513,14 +527,12 @@ namespace mRemoteNG.Connection.Protocol.RDP
if (string.IsNullOrEmpty(domain))
{
- if (Settings.Default.EmptyCredentials == "windows")
+ _rdpClient.Domain = Settings.Default.EmptyCredentials switch
{
- _rdpClient.Domain = Environment.UserDomainName;
- }
- else if (Settings.Default.EmptyCredentials == "custom")
- {
- _rdpClient.Domain = Settings.Default.DefaultDomain;
- }
+ "windows" => Environment.UserDomainName,
+ "custom" => Settings.Default.DefaultDomain,
+ _ => _rdpClient.Domain
+ };
}
else
{
diff --git a/mRemoteNG/Properties/Settings.Designer.cs b/mRemoteNG/Properties/Settings.Designer.cs
index 0761bdf3..f439c9e4 100644
--- a/mRemoteNG/Properties/Settings.Designer.cs
+++ b/mRemoteNG/Properties/Settings.Designer.cs
@@ -3274,5 +3274,17 @@ namespace mRemoteNG.Properties {
this["ConDefaultRDPStartProgramWorkDir"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string UserViaAPDefault {
+ get {
+ return ((string)(this["UserViaAPDefault"]));
+ }
+ set {
+ this["UserViaAPDefault"] = value;
+ }
+ }
}
}
diff --git a/mRemoteNG/Properties/Settings.settings b/mRemoteNG/Properties/Settings.settings
index 4e642cf6..4cf0a13c 100644
--- a/mRemoteNG/Properties/Settings.settings
+++ b/mRemoteNG/Properties/Settings.settings
@@ -815,5 +815,8 @@
<Setting Name="ConDefaultRDPStartProgramWorkDir" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
+ <Setting Name="UserViaAPDefault" Type="System.String" Scope="User">
+ <Value Profile="(Default)" />
+ </Setting>
</Settings>
</SettingsFile> \ No newline at end of file
diff --git a/mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.Designer.cs b/mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.Designer.cs
index 7a11683a..e7fd5d6e 100644
--- a/mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.Designer.cs
+++ b/mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.Designer.cs
@@ -55,7 +55,7 @@
this.pnlDefaultCredentials.Controls.Add(this.radCredentialsWindows);
this.pnlDefaultCredentials.Location = new System.Drawing.Point(3, 3);
this.pnlDefaultCredentials.Name = "pnlDefaultCredentials";
- this.pnlDefaultCredentials.Size = new System.Drawing.Size(604, 167);
+ this.pnlDefaultCredentials.Size = new System.Drawing.Size(604, 200);
this.pnlDefaultCredentials.TabIndex = 0;
//
// tableLayoutPanel1
@@ -77,7 +77,7 @@
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
- this.tableLayoutPanel1.Size = new System.Drawing.Size(332, 82);
+ this.tableLayoutPanel1.Size = new System.Drawing.Size(332, 110);
this.tableLayoutPanel1.TabIndex = 1;
//
// txtCredentialsUserViaAPI
diff --git a/mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.cs b/mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.cs
index 50c6982f..242efec2 100644
--- a/mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.cs
+++ b/mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.cs
@@ -54,6 +54,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
txtCredentialsPassword.Text =
cryptographyProvider.Decrypt(Settings.Default.DefaultPassword, Runtime.EncryptionKey);
txtCredentialsDomain.Text = Settings.Default.DefaultDomain;
+ txtCredentialsUserViaAPI.Text = Settings.Default.UserViaAPDefault;
}
public override void SaveSettings()
@@ -76,6 +77,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
Settings.Default.DefaultPassword =
cryptographyProvider.Encrypt(txtCredentialsPassword.Text, Runtime.EncryptionKey);
Settings.Default.DefaultDomain = txtCredentialsDomain.Text;
+ Settings.Default.UserViaAPDefault = txtCredentialsUserViaAPI.Text;
}
private void radCredentialsCustom_CheckedChanged(object sender, EventArgs e)
@@ -86,6 +88,8 @@ namespace mRemoteNG.UI.Forms.OptionsPages
txtCredentialsUsername.Enabled = radCredentialsCustom.Checked;
txtCredentialsPassword.Enabled = radCredentialsCustom.Checked;
txtCredentialsDomain.Enabled = radCredentialsCustom.Checked;
+ txtCredentialsUserViaAPI.Enabled = radCredentialsCustom.Checked;
+ lblCredentialsUserViaAPI.Enabled = radCredentialsCustom.Checked;
}
}
} \ No newline at end of file