mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
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
This commit is contained in:
@@ -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))
|
||||
|
||||
if (string.IsNullOrEmpty(username))
|
||||
{
|
||||
username = InterfaceControl.Info.Username;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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")
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
12
mRemoteNG/Properties/Settings.Designer.cs
generated
12
mRemoteNG/Properties/Settings.Designer.cs
generated
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user