From 348b0c728c5d665af4d306925be01a585ae42db3 Mon Sep 17 00:00:00 2001 From: Pedro Rodrigues Date: Thu, 14 Sep 2017 20:16:33 +0100 Subject: [PATCH] fallback to empty credentials settings in external apps #492 --- mRemoteV1/Tools/ExternalToolArgumentParser.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mRemoteV1/Tools/ExternalToolArgumentParser.cs b/mRemoteV1/Tools/ExternalToolArgumentParser.cs index b450b0a7..43cd16bd 100644 --- a/mRemoteV1/Tools/ExternalToolArgumentParser.cs +++ b/mRemoteV1/Tools/ExternalToolArgumentParser.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using mRemoteNG.Connection; +using mRemoteNG.Security.SymmetricEncryption; +using mRemoteNG.App; namespace mRemoteNG.Tools { @@ -169,12 +171,26 @@ namespace mRemoteNG.Tools break; case "username": replacement = _connectionInfo.Username; + if (string.IsNullOrEmpty(replacement)) + if (Settings.Default.EmptyCredentials == "windows") + replacement = Environment.UserName; + else if (Settings.Default.EmptyCredentials == "custom") + replacement = Settings.Default.DefaultUsername; break; case "password": replacement = _connectionInfo.Password; + if (string.IsNullOrEmpty(replacement) && Settings.Default.EmptyCredentials == "custom") + replacement = new LegacyRijndaelCryptographyProvider() + .Decrypt(Convert.ToString(Settings.Default.DefaultPassword), + Runtime.EncryptionKey); break; case "domain": replacement = _connectionInfo.Domain; + if (string.IsNullOrEmpty(replacement)) + if (Settings.Default.EmptyCredentials == "windows") + replacement = Environment.UserDomainName; + else if (Settings.Default.EmptyCredentials == "custom") + replacement = Settings.Default.DefaultDomain; break; case "description": replacement = _connectionInfo.Description;