diff options
author | Dimitrij <kvarkas@gmail.com> | 2022-01-28 16:50:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 16:50:31 +0300 |
commit | 58d0778c3dd5186e7cd12c38df7fe2522687342e (patch) | |
tree | be599531c6c7a9a0bb7b27d6ff6e740e02ea7d6f /mRemoteNG | |
parent | 81a542297416e4055e4b7fe8b9ada7a048cf82e3 (diff) | |
parent | eb859e5edec78ab92eadc2df8eabca6cdf3edf8a (diff) |
Merge pull request #2145 from jacko873/Dev
External Connectors, Default Options updated
Diffstat (limited to 'mRemoteNG')
-rw-r--r-- | mRemoteNG/Connection/Protocol/PuttyBase.cs | 42 | ||||
-rw-r--r-- | mRemoteNG/Connection/Protocol/RDP/RdpProtocol6.cs | 40 | ||||
-rw-r--r-- | mRemoteNG/Properties/Settings.Designer.cs | 12 | ||||
-rw-r--r-- | mRemoteNG/Properties/Settings.settings | 3 | ||||
-rw-r--r-- | mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.Designer.cs | 4 | ||||
-rw-r--r-- | mRemoteNG/UI/Forms/OptionsPages/CredentialsPage.cs | 4 |
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 |