mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
rename class from mssql to sql
This class is not dedicated to mssql but is used by all sql databases. Rename to reflect this.
This commit is contained in:
@@ -1,282 +1,282 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Security;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.Http;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class DataTableDeserializer : IDeserializer<DataTable, ConnectionTreeModel>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _decryptionKey;
|
||||
|
||||
public DataTableDeserializer(ICryptographyProvider cryptographyProvider, SecureString decryptionKey)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
_decryptionKey = decryptionKey.ThrowIfNull(nameof(decryptionKey));
|
||||
}
|
||||
|
||||
public ConnectionTreeModel Deserialize(DataTable table)
|
||||
{
|
||||
var connectionList = CreateNodesFromTable(table);
|
||||
var connectionTreeModel = CreateNodeHierarchy(connectionList, table);
|
||||
Runtime.ConnectionsService.IsConnectionsFileLoaded = true;
|
||||
return connectionTreeModel;
|
||||
}
|
||||
|
||||
private List<ConnectionInfo> CreateNodesFromTable(DataTable table)
|
||||
{
|
||||
var nodeList = new List<ConnectionInfo>();
|
||||
foreach (DataRow row in table.Rows)
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch ((string)row["Type"])
|
||||
{
|
||||
case "Connection":
|
||||
nodeList.Add(DeserializeConnectionInfo(row));
|
||||
break;
|
||||
case "Container":
|
||||
nodeList.Add(DeserializeContainerInfo(row));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nodeList;
|
||||
}
|
||||
|
||||
private ConnectionInfo DeserializeConnectionInfo(DataRow row)
|
||||
{
|
||||
var connectionId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
PopulateConnectionInfoFromDatarow(row, connectionInfo);
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
private ContainerInfo DeserializeContainerInfo(DataRow row)
|
||||
{
|
||||
var containerId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var containerInfo = new ContainerInfo(containerId);
|
||||
PopulateConnectionInfoFromDatarow(row, containerInfo);
|
||||
return containerInfo;
|
||||
}
|
||||
|
||||
private void PopulateConnectionInfoFromDatarow(DataRow dataRow, ConnectionInfo connectionInfo)
|
||||
{
|
||||
connectionInfo.Name = (string)dataRow["Name"];
|
||||
|
||||
// This throws a NPE - Parent is a connectionInfo object which will be null at this point.
|
||||
// The Parent object is linked properly later in CreateNodeHierarchy()
|
||||
//connectionInfo.Parent.ConstantID = (string)dataRow["ParentID"];
|
||||
|
||||
connectionInfo.Description = (string)dataRow["Description"];
|
||||
connectionInfo.Icon = (string)dataRow["Icon"];
|
||||
connectionInfo.Panel = (string)dataRow["Panel"];
|
||||
//connectionInfo.ExternalCredentialProvider = (ExternalCredentialProvider)Enum.Parse(typeof(ExternalCredentialProvider), (string)dataRow["ExternalCredentialProvider"]);
|
||||
//connectionInfo.UserViaAPI = (string)dataRow["UserViaAPI"];
|
||||
connectionInfo.Username = (string)dataRow["Username"];
|
||||
connectionInfo.Domain = (string)dataRow["Domain"];
|
||||
connectionInfo.Password = DecryptValue((string)dataRow["Password"]);
|
||||
connectionInfo.Hostname = (string)dataRow["Hostname"];
|
||||
//connectionInfo.ExternalAddressProvider = (ExternalAddressProvider)Enum.Parse(typeof(ExternalAddressProvider), (string)dataRow["ExternalAddressProvider"]);
|
||||
//connectionInfo.EC2Region = (string)dataRow["EC2Region"];
|
||||
//connectionInfo.EC2InstanceId = (string)dataRow["EC2InstanceId"];
|
||||
connectionInfo.VmId = (string)dataRow["VmId"];
|
||||
connectionInfo.UseEnhancedMode = (bool)dataRow["UseEnhancedMode"];
|
||||
connectionInfo.Protocol = (ProtocolType)Enum.Parse(typeof(ProtocolType), (string)dataRow["Protocol"]);
|
||||
connectionInfo.SSHTunnelConnectionName = (string)dataRow["SSHTunnelConnectionName"];
|
||||
connectionInfo.OpeningCommand = (string)dataRow["OpeningCommand"];
|
||||
connectionInfo.SSHOptions = (string)dataRow["SSHOptions"];
|
||||
connectionInfo.PuttySession = (string)dataRow["PuttySession"];
|
||||
connectionInfo.Port = (int)dataRow["Port"];
|
||||
connectionInfo.UseConsoleSession = (bool)dataRow["ConnectToConsole"];
|
||||
connectionInfo.UseCredSsp = (bool)dataRow["UseCredSsp"];
|
||||
connectionInfo.UseRestrictedAdmin = (bool)dataRow["UseRestrictedAdmin"];
|
||||
connectionInfo.UseRCG = (bool)dataRow["UseRCG"];
|
||||
connectionInfo.UseVmId = (bool)dataRow["UseVmId"];
|
||||
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)Enum.Parse(typeof(HTTPBase.RenderingEngine), (string)dataRow["RenderingEngine"]);
|
||||
connectionInfo.RDPAuthenticationLevel = (AuthenticationLevel)Enum.Parse(typeof(AuthenticationLevel), (string)dataRow["RDPAuthenticationLevel"]);
|
||||
connectionInfo.RDPMinutesToIdleTimeout = (int)dataRow["RDPMinutesToIdleTimeout"];
|
||||
connectionInfo.RDPAlertIdleTimeout = (bool)dataRow["RDPAlertIdleTimeout"];
|
||||
connectionInfo.LoadBalanceInfo = (string)dataRow["LoadBalanceInfo"];
|
||||
connectionInfo.Colors = (RDPColors)Enum.Parse(typeof(RDPColors), (string)dataRow["Colors"]);
|
||||
connectionInfo.Resolution = (RDPResolutions)Enum.Parse(typeof(RDPResolutions), (string)dataRow["Resolution"]);
|
||||
connectionInfo.AutomaticResize = (bool)dataRow["AutomaticResize"];
|
||||
connectionInfo.DisplayWallpaper = (bool)dataRow["DisplayWallpaper"];
|
||||
connectionInfo.DisplayThemes = (bool)dataRow["DisplayThemes"];
|
||||
connectionInfo.EnableFontSmoothing = (bool)dataRow["EnableFontSmoothing"];
|
||||
connectionInfo.EnableDesktopComposition = (bool)dataRow["EnableDesktopComposition"];
|
||||
connectionInfo.DisableFullWindowDrag = (bool)dataRow["DisableFullWindowDrag"];
|
||||
connectionInfo.DisableMenuAnimations = (bool)dataRow["DisableMenuAnimations"];
|
||||
connectionInfo.DisableCursorShadow = (bool)dataRow["DisableCursorShadow"];
|
||||
connectionInfo.DisableCursorBlinking = (bool)dataRow["DisableCursorBlinking"];
|
||||
connectionInfo.CacheBitmaps = (bool)dataRow["CacheBitmaps"];
|
||||
connectionInfo.RedirectDiskDrives = (RDPDiskDrives)Enum.Parse(typeof(RDPDiskDrives), (string)dataRow["RedirectDiskDrives"]);
|
||||
connectionInfo.RedirectDiskDrivesCustom = (string)dataRow["RedirectDiskDrivesCustom"];
|
||||
connectionInfo.RedirectPorts = (bool)dataRow["RedirectPorts"];
|
||||
connectionInfo.RedirectPrinters = (bool)dataRow["RedirectPrinters"];
|
||||
connectionInfo.RedirectClipboard = (bool)dataRow["RedirectClipboard"];
|
||||
connectionInfo.RedirectSmartCards = (bool)dataRow["RedirectSmartCards"];
|
||||
connectionInfo.RedirectSound = (RDPSounds)Enum.Parse(typeof(RDPSounds), (string)dataRow["RedirectSound"]);
|
||||
connectionInfo.SoundQuality = (RDPSoundQuality)Enum.Parse(typeof(RDPSoundQuality), (string)dataRow["SoundQuality"]);
|
||||
connectionInfo.RedirectAudioCapture = (bool)dataRow["RedirectAudioCapture"];
|
||||
connectionInfo.RDPStartProgram = (string)dataRow["StartProgram"];
|
||||
connectionInfo.RDPStartProgramWorkDir = (string)dataRow["StartProgramWorkDir"];
|
||||
connectionInfo.RedirectKeys = (bool)dataRow["RedirectKeys"];
|
||||
connectionInfo.OpeningCommand = (string)dataRow["OpeningCommand"];
|
||||
connectionInfo.PreExtApp = (string)dataRow["PreExtApp"];
|
||||
connectionInfo.PostExtApp = (string)dataRow["PostExtApp"];
|
||||
connectionInfo.MacAddress = (string)dataRow["MacAddress"];
|
||||
connectionInfo.UserField = (string)dataRow["UserField"];
|
||||
connectionInfo.ExtApp = (string)dataRow["ExtApp"];
|
||||
connectionInfo.VNCCompression = (ProtocolVNC.Compression)Enum.Parse(typeof(ProtocolVNC.Compression), (string)dataRow["VNCCompression"]);
|
||||
connectionInfo.VNCEncoding = (ProtocolVNC.Encoding)Enum.Parse(typeof(ProtocolVNC.Encoding), (string)dataRow["VNCEncoding"]);
|
||||
connectionInfo.VNCAuthMode = (ProtocolVNC.AuthMode)Enum.Parse(typeof(ProtocolVNC.AuthMode), (string)dataRow["VNCAuthMode"]);
|
||||
connectionInfo.VNCProxyType = (ProtocolVNC.ProxyType)Enum.Parse(typeof(ProtocolVNC.ProxyType), (string)dataRow["VNCProxyType"]);
|
||||
connectionInfo.VNCProxyIP = (string)dataRow["VNCProxyIP"];
|
||||
connectionInfo.VNCProxyPort = (int)dataRow["VNCProxyPort"];
|
||||
connectionInfo.VNCProxyUsername = (string)dataRow["VNCProxyUsername"];
|
||||
connectionInfo.VNCProxyPassword = DecryptValue((string)dataRow["VNCProxyPassword"]);
|
||||
connectionInfo.VNCColors = (ProtocolVNC.Colors)Enum.Parse(typeof(ProtocolVNC.Colors), (string)dataRow["VNCColors"]);
|
||||
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Enum.Parse(typeof(ProtocolVNC.SmartSizeMode), (string)dataRow["VNCSmartSizeMode"]);
|
||||
connectionInfo.VNCViewOnly = (bool)dataRow["VNCViewOnly"];
|
||||
connectionInfo.RDGatewayUsageMethod = (RDGatewayUsageMethod)Enum.Parse(typeof(RDGatewayUsageMethod), (string)dataRow["RDGatewayUsageMethod"]);
|
||||
connectionInfo.RDGatewayHostname = (string)dataRow["RDGatewayHostname"];
|
||||
connectionInfo.RDGatewayUseConnectionCredentials = (RDGatewayUseConnectionCredentials)Enum.Parse(typeof(RDGatewayUseConnectionCredentials), (string)dataRow["RDGatewayUseConnectionCredentials"]);
|
||||
connectionInfo.RDGatewayUsername = (string)dataRow["RDGatewayUsername"];
|
||||
connectionInfo.RDGatewayPassword = DecryptValue((string)dataRow["RDGatewayPassword"]);
|
||||
connectionInfo.RDGatewayDomain = (string)dataRow["RDGatewayDomain"];
|
||||
//connectionInfo.RDGatewayExternalCredentialProvider = (ExternalCredentialProvider)Enum.Parse(typeof(ExternalCredentialProvider), (string)dataRow["RDGatewayExternalCredentialProvider"]);
|
||||
//connectionInfo.RDGatewayUserViaAPI = (string)dataRow["RDGatewayUserViaAPI"];
|
||||
|
||||
if (!dataRow.IsNull("RdpVersion")) // table allows null values which must be handled
|
||||
if (Enum.TryParse((string)dataRow["RdpVersion"], true, out RdpVersion rdpVersion))
|
||||
connectionInfo.RdpVersion = rdpVersion;
|
||||
|
||||
connectionInfo.Inheritance.CacheBitmaps = (bool)dataRow["InheritCacheBitmaps"];
|
||||
connectionInfo.Inheritance.Colors = (bool)dataRow["InheritColors"];
|
||||
connectionInfo.Inheritance.Description = (bool)dataRow["InheritDescription"];
|
||||
connectionInfo.Inheritance.DisplayThemes = (bool)dataRow["InheritDisplayThemes"];
|
||||
connectionInfo.Inheritance.DisplayWallpaper = (bool)dataRow["InheritDisplayWallpaper"];
|
||||
connectionInfo.Inheritance.EnableFontSmoothing = (bool)dataRow["InheritEnableFontSmoothing"];
|
||||
connectionInfo.Inheritance.EnableDesktopComposition = (bool)dataRow["InheritEnableDesktopComposition"];
|
||||
connectionInfo.Inheritance.DisableFullWindowDrag = (bool)dataRow["InheritDisableFullWindowDrag"];
|
||||
connectionInfo.Inheritance.DisableMenuAnimations = (bool)dataRow["InheritDisableMenuAnimations"];
|
||||
connectionInfo.Inheritance.DisableCursorShadow = (bool)dataRow["InheritDisableCursorShadow"];
|
||||
connectionInfo.Inheritance.DisableCursorBlinking = (bool)dataRow["InheritDisableCursorBlinking"];
|
||||
//connectionInfo.Inheritance.ExternalCredentialProvider = (bool)dataRow["InheritExternalCredentialProvider"];
|
||||
//connectionInfo.Inheritance.UserViaAPI = (bool)dataRow["InheritUserViaAPI"];
|
||||
connectionInfo.Inheritance.Domain = (bool)dataRow["InheritDomain"];
|
||||
connectionInfo.Inheritance.Icon = (bool)dataRow["InheritIcon"];
|
||||
connectionInfo.Inheritance.Panel = (bool)dataRow["InheritPanel"];
|
||||
connectionInfo.Inheritance.Password = (bool)dataRow["InheritPassword"];
|
||||
connectionInfo.Inheritance.Port = (bool)dataRow["InheritPort"];
|
||||
connectionInfo.Inheritance.Protocol = (bool)dataRow["InheritProtocol"];
|
||||
connectionInfo.Inheritance.SSHTunnelConnectionName = (bool)dataRow["InheritSSHTunnelConnectionName"];
|
||||
connectionInfo.Inheritance.OpeningCommand = (bool)dataRow["InheritOpeningCommand"];
|
||||
connectionInfo.Inheritance.SSHOptions = (bool)dataRow["InheritSSHOptions"];
|
||||
connectionInfo.Inheritance.PuttySession = (bool)dataRow["InheritPuttySession"];
|
||||
connectionInfo.Inheritance.RedirectDiskDrives = (bool)dataRow["InheritRedirectDiskDrives"];
|
||||
connectionInfo.Inheritance.RedirectDiskDrivesCustom = (bool)dataRow["InheritRedirectDiskDrivesCustom"];
|
||||
connectionInfo.Inheritance.RedirectKeys = (bool)dataRow["InheritRedirectKeys"];
|
||||
connectionInfo.Inheritance.RedirectPorts = (bool)dataRow["InheritRedirectPorts"];
|
||||
connectionInfo.Inheritance.RedirectPrinters = (bool)dataRow["InheritRedirectPrinters"];
|
||||
connectionInfo.Inheritance.RedirectClipboard = (bool)dataRow["InheritRedirectClipboard"];
|
||||
connectionInfo.Inheritance.RedirectSmartCards = (bool)dataRow["InheritRedirectSmartCards"];
|
||||
connectionInfo.Inheritance.RedirectSound = (bool)dataRow["InheritRedirectSound"];
|
||||
connectionInfo.Inheritance.SoundQuality = (bool)dataRow["InheritSoundQuality"];
|
||||
connectionInfo.Inheritance.RedirectAudioCapture = (bool)dataRow["InheritRedirectAudioCapture"];
|
||||
connectionInfo.Inheritance.Resolution = (bool)dataRow["InheritResolution"];
|
||||
connectionInfo.Inheritance.AutomaticResize = (bool)dataRow["InheritAutomaticResize"];
|
||||
connectionInfo.Inheritance.UseConsoleSession = (bool)dataRow["InheritUseConsoleSession"];
|
||||
connectionInfo.Inheritance.UseCredSsp = (bool)dataRow["InheritUseCredSsp"];
|
||||
connectionInfo.Inheritance.UseRestrictedAdmin = (bool)dataRow["InheritUseRestrictedAdmin"];
|
||||
connectionInfo.Inheritance.UseRCG = (bool)dataRow["InheritUseRCG"];
|
||||
connectionInfo.Inheritance.UseVmId = (bool)dataRow["InheritUseVmId"];
|
||||
connectionInfo.Inheritance.UseEnhancedMode = (bool)dataRow["InheritUseEnhancedMode"];
|
||||
connectionInfo.Inheritance.VmId = (bool)dataRow["InheritVmId"];
|
||||
connectionInfo.Inheritance.RenderingEngine = (bool)dataRow["InheritRenderingEngine"];
|
||||
connectionInfo.Inheritance.Username = (bool)dataRow["InheritUsername"];
|
||||
connectionInfo.Inheritance.RDPAuthenticationLevel = (bool)dataRow["InheritRDPAuthenticationLevel"];
|
||||
connectionInfo.Inheritance.RDPAlertIdleTimeout = (bool)dataRow["InheritRDPAlertIdleTimeout"];
|
||||
connectionInfo.Inheritance.RDPMinutesToIdleTimeout = (bool)dataRow["InheritRDPMinutesToIdleTimeout"];
|
||||
connectionInfo.Inheritance.LoadBalanceInfo = (bool)dataRow["InheritLoadBalanceInfo"];
|
||||
connectionInfo.Inheritance.OpeningCommand = (bool)dataRow["InheritOpeningCommand"];
|
||||
connectionInfo.Inheritance.PreExtApp = (bool)dataRow["InheritPreExtApp"];
|
||||
connectionInfo.Inheritance.PostExtApp = (bool)dataRow["InheritPostExtApp"];
|
||||
connectionInfo.Inheritance.MacAddress = (bool)dataRow["InheritMacAddress"];
|
||||
connectionInfo.Inheritance.UserField = (bool)dataRow["InheritUserField"];
|
||||
connectionInfo.Inheritance.ExtApp = (bool)dataRow["InheritExtApp"];
|
||||
connectionInfo.Inheritance.VNCCompression = (bool)dataRow["InheritVNCCompression"];
|
||||
connectionInfo.Inheritance.VNCEncoding = (bool)dataRow["InheritVNCEncoding"];
|
||||
connectionInfo.Inheritance.VNCAuthMode = (bool)dataRow["InheritVNCAuthMode"];
|
||||
connectionInfo.Inheritance.VNCProxyType = (bool)dataRow["InheritVNCProxyType"];
|
||||
connectionInfo.Inheritance.VNCProxyIP = (bool)dataRow["InheritVNCProxyIP"];
|
||||
connectionInfo.Inheritance.VNCProxyPort = (bool)dataRow["InheritVNCProxyPort"];
|
||||
connectionInfo.Inheritance.VNCProxyUsername = (bool)dataRow["InheritVNCProxyUsername"];
|
||||
connectionInfo.Inheritance.VNCProxyPassword = (bool)dataRow["InheritVNCProxyPassword"];
|
||||
connectionInfo.Inheritance.VNCColors = (bool)dataRow["InheritVNCColors"];
|
||||
connectionInfo.Inheritance.VNCSmartSizeMode = (bool)dataRow["InheritVNCSmartSizeMode"];
|
||||
connectionInfo.Inheritance.VNCViewOnly = (bool)dataRow["InheritVNCViewOnly"];
|
||||
connectionInfo.Inheritance.RDGatewayUsageMethod = (bool)dataRow["InheritRDGatewayUsageMethod"];
|
||||
connectionInfo.Inheritance.RDGatewayHostname = (bool)dataRow["InheritRDGatewayHostname"];
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials = (bool)dataRow["InheritRDGatewayUseConnectionCredentials"];
|
||||
connectionInfo.Inheritance.RDGatewayUsername = (bool)dataRow["InheritRDGatewayUsername"];
|
||||
connectionInfo.Inheritance.RDGatewayPassword = (bool)dataRow["InheritRDGatewayPassword"];
|
||||
connectionInfo.Inheritance.RDGatewayDomain = (bool)dataRow["InheritRDGatewayDomain"];
|
||||
//connectionInfo.Inheritance.RDGatewayExternalCredentialProvider = (bool)dataRow["InheritRDGatewayExternalCredentialProvider"];
|
||||
//connectionInfo.Inheritance.RDGatewayUserViaAPI = (bool)dataRow["InheritRDGatewayUserViaAPI"];
|
||||
connectionInfo.Inheritance.RdpVersion = (bool)dataRow["InheritRdpVersion"];
|
||||
}
|
||||
|
||||
private string DecryptValue(string cipherText)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _cryptographyProvider.Decrypt(cipherText, _decryptionKey);
|
||||
}
|
||||
catch (EncryptionException)
|
||||
{
|
||||
// value may not be encrypted
|
||||
return cipherText;
|
||||
}
|
||||
}
|
||||
|
||||
private ConnectionTreeModel CreateNodeHierarchy(List<ConnectionInfo> connectionList, DataTable dataTable)
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var rootNode = new RootNodeInfo(RootNodeType.Connection, "0")
|
||||
{
|
||||
PasswordString = _decryptionKey.ConvertToUnsecureString()
|
||||
};
|
||||
connectionTreeModel.AddRootNode(rootNode);
|
||||
|
||||
foreach (DataRow row in dataTable.Rows)
|
||||
{
|
||||
var id = (string)row["ConstantID"];
|
||||
var connectionInfo = connectionList.First(node => node.ConstantID == id);
|
||||
var parentId = (string)row["ParentID"];
|
||||
if (parentId == "0" || connectionList.All(node => node.ConstantID != parentId))
|
||||
rootNode.AddChild(connectionInfo);
|
||||
else
|
||||
(connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(
|
||||
connectionInfo);
|
||||
}
|
||||
|
||||
return connectionTreeModel;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Security;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Connection.Protocol.Http;
|
||||
using mRemoteNG.Connection.Protocol.RDP;
|
||||
using mRemoteNG.Connection.Protocol.VNC;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Sql
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class DataTableDeserializer : IDeserializer<DataTable, ConnectionTreeModel>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _decryptionKey;
|
||||
|
||||
public DataTableDeserializer(ICryptographyProvider cryptographyProvider, SecureString decryptionKey)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
_decryptionKey = decryptionKey.ThrowIfNull(nameof(decryptionKey));
|
||||
}
|
||||
|
||||
public ConnectionTreeModel Deserialize(DataTable table)
|
||||
{
|
||||
var connectionList = CreateNodesFromTable(table);
|
||||
var connectionTreeModel = CreateNodeHierarchy(connectionList, table);
|
||||
Runtime.ConnectionsService.IsConnectionsFileLoaded = true;
|
||||
return connectionTreeModel;
|
||||
}
|
||||
|
||||
private List<ConnectionInfo> CreateNodesFromTable(DataTable table)
|
||||
{
|
||||
var nodeList = new List<ConnectionInfo>();
|
||||
foreach (DataRow row in table.Rows)
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch ((string)row["Type"])
|
||||
{
|
||||
case "Connection":
|
||||
nodeList.Add(DeserializeConnectionInfo(row));
|
||||
break;
|
||||
case "Container":
|
||||
nodeList.Add(DeserializeContainerInfo(row));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return nodeList;
|
||||
}
|
||||
|
||||
private ConnectionInfo DeserializeConnectionInfo(DataRow row)
|
||||
{
|
||||
var connectionId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var connectionInfo = new ConnectionInfo(connectionId);
|
||||
PopulateConnectionInfoFromDatarow(row, connectionInfo);
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
private ContainerInfo DeserializeContainerInfo(DataRow row)
|
||||
{
|
||||
var containerId = row["ConstantID"] as string ?? Guid.NewGuid().ToString();
|
||||
var containerInfo = new ContainerInfo(containerId);
|
||||
PopulateConnectionInfoFromDatarow(row, containerInfo);
|
||||
return containerInfo;
|
||||
}
|
||||
|
||||
private void PopulateConnectionInfoFromDatarow(DataRow dataRow, ConnectionInfo connectionInfo)
|
||||
{
|
||||
connectionInfo.Name = (string)dataRow["Name"];
|
||||
|
||||
// This throws a NPE - Parent is a connectionInfo object which will be null at this point.
|
||||
// The Parent object is linked properly later in CreateNodeHierarchy()
|
||||
//connectionInfo.Parent.ConstantID = (string)dataRow["ParentID"];
|
||||
|
||||
//connectionInfo.EC2InstanceId = (string)dataRow["EC2InstanceId"];
|
||||
//connectionInfo.EC2Region = (string)dataRow["EC2Region"];
|
||||
//connectionInfo.ExternalAddressProvider = (ExternalAddressProvider)Enum.Parse(typeof(ExternalAddressProvider), (string)dataRow["ExternalAddressProvider"]);
|
||||
//connectionInfo.ExternalCredentialProvider = (ExternalCredentialProvider)Enum.Parse(typeof(ExternalCredentialProvider), (string)dataRow["ExternalCredentialProvider"]);
|
||||
//connectionInfo.RDGatewayExternalCredentialProvider = (ExternalCredentialProvider)Enum.Parse(typeof(ExternalCredentialProvider), (string)dataRow["RDGatewayExternalCredentialProvider"]);
|
||||
//connectionInfo.RDGatewayUserViaAPI = (string)dataRow["RDGatewayUserViaAPI"];
|
||||
//connectionInfo.UserViaAPI = (string)dataRow["UserViaAPI"];
|
||||
connectionInfo.AutomaticResize = MiscTools.GetBooleanValue(dataRow["AutomaticResize"]);
|
||||
connectionInfo.CacheBitmaps = MiscTools.GetBooleanValue(dataRow["CacheBitmaps"]);
|
||||
connectionInfo.Colors = (RDPColors)Enum.Parse(typeof(RDPColors), (string)dataRow["Colors"]);
|
||||
connectionInfo.Description = (string)dataRow["Description"];
|
||||
connectionInfo.DisableCursorBlinking = MiscTools.GetBooleanValue(dataRow["DisableCursorBlinking"]);
|
||||
connectionInfo.DisableCursorShadow = MiscTools.GetBooleanValue(dataRow["DisableCursorShadow"]);
|
||||
connectionInfo.DisableFullWindowDrag = MiscTools.GetBooleanValue(dataRow["DisableFullWindowDrag"]);
|
||||
connectionInfo.DisableMenuAnimations = MiscTools.GetBooleanValue(dataRow["DisableMenuAnimations"]);
|
||||
connectionInfo.DisplayThemes = MiscTools.GetBooleanValue(dataRow["DisplayThemes"]);
|
||||
connectionInfo.DisplayWallpaper = MiscTools.GetBooleanValue(dataRow["DisplayWallpaper"]);
|
||||
connectionInfo.Domain = (string)dataRow["Domain"];
|
||||
connectionInfo.EnableDesktopComposition = MiscTools.GetBooleanValue(dataRow["EnableDesktopComposition"]);
|
||||
connectionInfo.EnableFontSmoothing = MiscTools.GetBooleanValue(dataRow["EnableFontSmoothing"]);
|
||||
connectionInfo.ExtApp = (string)dataRow["ExtApp"];
|
||||
connectionInfo.Hostname = (string)dataRow["Hostname"];
|
||||
connectionInfo.Icon = (string)dataRow["Icon"];
|
||||
connectionInfo.LoadBalanceInfo = (string)dataRow["LoadBalanceInfo"];
|
||||
connectionInfo.MacAddress = (string)dataRow["MacAddress"];
|
||||
connectionInfo.OpeningCommand = (string)dataRow["OpeningCommand"];
|
||||
connectionInfo.OpeningCommand = (string)dataRow["OpeningCommand"];
|
||||
connectionInfo.Panel = (string)dataRow["Panel"];
|
||||
connectionInfo.Password = DecryptValue((string)dataRow["Password"]);
|
||||
connectionInfo.Port = (int)dataRow["Port"];
|
||||
connectionInfo.PostExtApp = (string)dataRow["PostExtApp"];
|
||||
connectionInfo.PreExtApp = (string)dataRow["PreExtApp"];
|
||||
connectionInfo.Protocol = (ProtocolType)Enum.Parse(typeof(ProtocolType), (string)dataRow["Protocol"]);
|
||||
connectionInfo.PuttySession = (string)dataRow["PuttySession"];
|
||||
connectionInfo.RDGatewayDomain = (string)dataRow["RDGatewayDomain"];
|
||||
connectionInfo.RDGatewayHostname = (string)dataRow["RDGatewayHostname"];
|
||||
connectionInfo.RDGatewayPassword = DecryptValue((string)dataRow["RDGatewayPassword"]);
|
||||
connectionInfo.RDGatewayUsageMethod = (RDGatewayUsageMethod)Enum.Parse(typeof(RDGatewayUsageMethod), (string)dataRow["RDGatewayUsageMethod"]);
|
||||
connectionInfo.RDGatewayUseConnectionCredentials = (RDGatewayUseConnectionCredentials)Enum.Parse(typeof(RDGatewayUseConnectionCredentials), (string)dataRow["RDGatewayUseConnectionCredentials"]);
|
||||
connectionInfo.RDGatewayUsername = (string)dataRow["RDGatewayUsername"];
|
||||
connectionInfo.RDPAlertIdleTimeout = MiscTools.GetBooleanValue(dataRow["RDPAlertIdleTimeout"]);
|
||||
connectionInfo.RDPAuthenticationLevel = (AuthenticationLevel)Enum.Parse(typeof(AuthenticationLevel), (string)dataRow["RDPAuthenticationLevel"]);
|
||||
connectionInfo.RDPMinutesToIdleTimeout = (int)dataRow["RDPMinutesToIdleTimeout"];
|
||||
connectionInfo.RDPStartProgram = (string)dataRow["StartProgram"];
|
||||
connectionInfo.RDPStartProgramWorkDir = (string)dataRow["StartProgramWorkDir"];
|
||||
connectionInfo.RedirectAudioCapture = MiscTools.GetBooleanValue(dataRow["RedirectAudioCapture"]);
|
||||
connectionInfo.RedirectClipboard = MiscTools.GetBooleanValue(dataRow["RedirectClipboard"]);
|
||||
connectionInfo.RedirectDiskDrives = (RDPDiskDrives)Enum.Parse(typeof(RDPDiskDrives), (string)dataRow["RedirectDiskDrives"]);
|
||||
connectionInfo.RedirectDiskDrivesCustom = (string)dataRow["RedirectDiskDrivesCustom"];
|
||||
connectionInfo.RedirectKeys = MiscTools.GetBooleanValue(dataRow["RedirectKeys"]);
|
||||
connectionInfo.RedirectPorts = MiscTools.GetBooleanValue(dataRow["RedirectPorts"]);
|
||||
connectionInfo.RedirectPrinters = MiscTools.GetBooleanValue(dataRow["RedirectPrinters"]);
|
||||
connectionInfo.RedirectSmartCards = MiscTools.GetBooleanValue(dataRow["RedirectSmartCards"]);
|
||||
connectionInfo.RedirectSound = (RDPSounds)Enum.Parse(typeof(RDPSounds), (string)dataRow["RedirectSound"]);
|
||||
connectionInfo.RenderingEngine = (HTTPBase.RenderingEngine)Enum.Parse(typeof(HTTPBase.RenderingEngine), (string)dataRow["RenderingEngine"]);
|
||||
connectionInfo.Resolution = (RDPResolutions)Enum.Parse(typeof(RDPResolutions), (string)dataRow["Resolution"]);
|
||||
connectionInfo.SoundQuality = (RDPSoundQuality)Enum.Parse(typeof(RDPSoundQuality), (string)dataRow["SoundQuality"]);
|
||||
connectionInfo.SSHOptions = (string)dataRow["SSHOptions"];
|
||||
connectionInfo.SSHTunnelConnectionName = (string)dataRow["SSHTunnelConnectionName"];
|
||||
connectionInfo.UseConsoleSession = MiscTools.GetBooleanValue(dataRow["ConnectToConsole"]);
|
||||
connectionInfo.UseCredSsp = MiscTools.GetBooleanValue(dataRow["UseCredSsp"]);
|
||||
connectionInfo.UseEnhancedMode = MiscTools.GetBooleanValue(dataRow["UseEnhancedMode"]);
|
||||
connectionInfo.UseRCG = MiscTools.GetBooleanValue(dataRow["UseRCG"]);
|
||||
connectionInfo.UseRestrictedAdmin = MiscTools.GetBooleanValue(dataRow["UseRestrictedAdmin"]);
|
||||
connectionInfo.UserField = (string)dataRow["UserField"];
|
||||
connectionInfo.Username = (string)dataRow["Username"];
|
||||
connectionInfo.UseVmId = MiscTools.GetBooleanValue(dataRow["UseVmId"]);
|
||||
connectionInfo.VmId = (string)dataRow["VmId"];
|
||||
connectionInfo.VNCAuthMode = (ProtocolVNC.AuthMode)Enum.Parse(typeof(ProtocolVNC.AuthMode), (string)dataRow["VNCAuthMode"]);
|
||||
connectionInfo.VNCColors = (ProtocolVNC.Colors)Enum.Parse(typeof(ProtocolVNC.Colors), (string)dataRow["VNCColors"]);
|
||||
connectionInfo.VNCCompression = (ProtocolVNC.Compression)Enum.Parse(typeof(ProtocolVNC.Compression), (string)dataRow["VNCCompression"]);
|
||||
connectionInfo.VNCEncoding = (ProtocolVNC.Encoding)Enum.Parse(typeof(ProtocolVNC.Encoding), (string)dataRow["VNCEncoding"]);
|
||||
connectionInfo.VNCProxyIP = (string)dataRow["VNCProxyIP"];
|
||||
connectionInfo.VNCProxyPassword = DecryptValue((string)dataRow["VNCProxyPassword"]);
|
||||
connectionInfo.VNCProxyPort = (int)dataRow["VNCProxyPort"];
|
||||
connectionInfo.VNCProxyType = (ProtocolVNC.ProxyType)Enum.Parse(typeof(ProtocolVNC.ProxyType), (string)dataRow["VNCProxyType"]);
|
||||
connectionInfo.VNCProxyUsername = (string)dataRow["VNCProxyUsername"];
|
||||
connectionInfo.VNCSmartSizeMode = (ProtocolVNC.SmartSizeMode)Enum.Parse(typeof(ProtocolVNC.SmartSizeMode), (string)dataRow["VNCSmartSizeMode"]);
|
||||
connectionInfo.VNCViewOnly = MiscTools.GetBooleanValue(dataRow["VNCViewOnly"]);
|
||||
|
||||
if (!dataRow.IsNull("RdpVersion")) // table allows null values which must be handled
|
||||
if (Enum.TryParse((string)dataRow["RdpVersion"], true, out RdpVersion rdpVersion))
|
||||
connectionInfo.RdpVersion = rdpVersion;
|
||||
|
||||
//connectionInfo.Inheritance.ExternalCredentialProvider = MiscTools.GetBooleanValue(dataRow["InheritExternalCredentialProvider"]);
|
||||
//connectionInfo.Inheritance.RDGatewayExternalCredentialProvider = MiscTools.GetBooleanValue(dataRow["InheritRDGatewayExternalCredentialProvider"]);
|
||||
//connectionInfo.Inheritance.RDGatewayUserViaAPI = MiscTools.GetBooleanValue(dataRow["InheritRDGatewayUserViaAPI"]);
|
||||
//connectionInfo.Inheritance.UserViaAPI = MiscTools.GetBooleanValue(dataRow["InheritUserViaAPI"]);
|
||||
connectionInfo.Inheritance.AutomaticResize = MiscTools.GetBooleanValue(dataRow["InheritAutomaticResize"]);
|
||||
connectionInfo.Inheritance.CacheBitmaps = MiscTools.GetBooleanValue(dataRow["InheritCacheBitmaps"]);
|
||||
connectionInfo.Inheritance.Colors = MiscTools.GetBooleanValue(dataRow["InheritColors"]);
|
||||
connectionInfo.Inheritance.Description = MiscTools.GetBooleanValue(dataRow["InheritDescription"]);
|
||||
connectionInfo.Inheritance.DisableCursorBlinking = MiscTools.GetBooleanValue(dataRow["InheritDisableCursorBlinking"]);
|
||||
connectionInfo.Inheritance.DisableCursorShadow = MiscTools.GetBooleanValue(dataRow["InheritDisableCursorShadow"]);
|
||||
connectionInfo.Inheritance.DisableFullWindowDrag = MiscTools.GetBooleanValue(dataRow["InheritDisableFullWindowDrag"]);
|
||||
connectionInfo.Inheritance.DisableMenuAnimations = MiscTools.GetBooleanValue(dataRow["InheritDisableMenuAnimations"]);
|
||||
connectionInfo.Inheritance.DisplayThemes = MiscTools.GetBooleanValue(dataRow["InheritDisplayThemes"]);
|
||||
connectionInfo.Inheritance.DisplayWallpaper = MiscTools.GetBooleanValue(dataRow["InheritDisplayWallpaper"]);
|
||||
connectionInfo.Inheritance.Domain = MiscTools.GetBooleanValue(dataRow["InheritDomain"]);
|
||||
connectionInfo.Inheritance.EnableDesktopComposition = MiscTools.GetBooleanValue(dataRow["InheritEnableDesktopComposition"]);
|
||||
connectionInfo.Inheritance.EnableFontSmoothing = MiscTools.GetBooleanValue(dataRow["InheritEnableFontSmoothing"]);
|
||||
connectionInfo.Inheritance.ExtApp = MiscTools.GetBooleanValue(dataRow["InheritExtApp"]);
|
||||
connectionInfo.Inheritance.Icon = MiscTools.GetBooleanValue(dataRow["InheritIcon"]);
|
||||
connectionInfo.Inheritance.LoadBalanceInfo = MiscTools.GetBooleanValue(dataRow["InheritLoadBalanceInfo"]);
|
||||
connectionInfo.Inheritance.MacAddress = MiscTools.GetBooleanValue(dataRow["InheritMacAddress"]);
|
||||
connectionInfo.Inheritance.OpeningCommand = MiscTools.GetBooleanValue(dataRow["InheritOpeningCommand"]);
|
||||
connectionInfo.Inheritance.OpeningCommand = MiscTools.GetBooleanValue(dataRow["InheritOpeningCommand"]);
|
||||
connectionInfo.Inheritance.Panel = MiscTools.GetBooleanValue(dataRow["InheritPanel"]);
|
||||
connectionInfo.Inheritance.Password = MiscTools.GetBooleanValue(dataRow["InheritPassword"]);
|
||||
connectionInfo.Inheritance.Port = MiscTools.GetBooleanValue(dataRow["InheritPort"]);
|
||||
connectionInfo.Inheritance.PostExtApp = MiscTools.GetBooleanValue(dataRow["InheritPostExtApp"]);
|
||||
connectionInfo.Inheritance.PreExtApp = MiscTools.GetBooleanValue(dataRow["InheritPreExtApp"]);
|
||||
connectionInfo.Inheritance.Protocol = MiscTools.GetBooleanValue(dataRow["InheritProtocol"]);
|
||||
connectionInfo.Inheritance.PuttySession = MiscTools.GetBooleanValue(dataRow["InheritPuttySession"]);
|
||||
connectionInfo.Inheritance.RDGatewayDomain = MiscTools.GetBooleanValue(dataRow["InheritRDGatewayDomain"]);
|
||||
connectionInfo.Inheritance.RDGatewayHostname = MiscTools.GetBooleanValue(dataRow["InheritRDGatewayHostname"]);
|
||||
connectionInfo.Inheritance.RDGatewayPassword = MiscTools.GetBooleanValue(dataRow["InheritRDGatewayPassword"]);
|
||||
connectionInfo.Inheritance.RDGatewayUsageMethod = MiscTools.GetBooleanValue(dataRow["InheritRDGatewayUsageMethod"]);
|
||||
connectionInfo.Inheritance.RDGatewayUseConnectionCredentials = MiscTools.GetBooleanValue(dataRow["InheritRDGatewayUseConnectionCredentials"]);
|
||||
connectionInfo.Inheritance.RDGatewayUsername = MiscTools.GetBooleanValue(dataRow["InheritRDGatewayUsername"]);
|
||||
connectionInfo.Inheritance.RDPAlertIdleTimeout = MiscTools.GetBooleanValue(dataRow["InheritRDPAlertIdleTimeout"]);
|
||||
connectionInfo.Inheritance.RDPAuthenticationLevel = MiscTools.GetBooleanValue(dataRow["InheritRDPAuthenticationLevel"]);
|
||||
connectionInfo.Inheritance.RDPMinutesToIdleTimeout = MiscTools.GetBooleanValue(dataRow["InheritRDPMinutesToIdleTimeout"]);
|
||||
connectionInfo.Inheritance.RdpVersion = MiscTools.GetBooleanValue(dataRow["InheritRdpVersion"]);
|
||||
connectionInfo.Inheritance.RedirectAudioCapture = MiscTools.GetBooleanValue(dataRow["InheritRedirectAudioCapture"]);
|
||||
connectionInfo.Inheritance.RedirectClipboard = MiscTools.GetBooleanValue(dataRow["InheritRedirectClipboard"]);
|
||||
connectionInfo.Inheritance.RedirectDiskDrives = MiscTools.GetBooleanValue(dataRow["InheritRedirectDiskDrives"]);
|
||||
connectionInfo.Inheritance.RedirectDiskDrivesCustom = MiscTools.GetBooleanValue(dataRow["InheritRedirectDiskDrivesCustom"]);
|
||||
connectionInfo.Inheritance.RedirectKeys = MiscTools.GetBooleanValue(dataRow["InheritRedirectKeys"]);
|
||||
connectionInfo.Inheritance.RedirectPorts = MiscTools.GetBooleanValue(dataRow["InheritRedirectPorts"]);
|
||||
connectionInfo.Inheritance.RedirectPrinters = MiscTools.GetBooleanValue(dataRow["InheritRedirectPrinters"]);
|
||||
connectionInfo.Inheritance.RedirectSmartCards = MiscTools.GetBooleanValue(dataRow["InheritRedirectSmartCards"]);
|
||||
connectionInfo.Inheritance.RedirectSound = MiscTools.GetBooleanValue(dataRow["InheritRedirectSound"]);
|
||||
connectionInfo.Inheritance.RenderingEngine = MiscTools.GetBooleanValue(dataRow["InheritRenderingEngine"]);
|
||||
connectionInfo.Inheritance.Resolution = MiscTools.GetBooleanValue(dataRow["InheritResolution"]);
|
||||
connectionInfo.Inheritance.SoundQuality = MiscTools.GetBooleanValue(dataRow["InheritSoundQuality"]);
|
||||
connectionInfo.Inheritance.SSHOptions = MiscTools.GetBooleanValue(dataRow["InheritSSHOptions"]);
|
||||
connectionInfo.Inheritance.SSHTunnelConnectionName = MiscTools.GetBooleanValue(dataRow["InheritSSHTunnelConnectionName"]);
|
||||
connectionInfo.Inheritance.UseConsoleSession = MiscTools.GetBooleanValue(dataRow["InheritUseConsoleSession"]);
|
||||
connectionInfo.Inheritance.UseCredSsp = MiscTools.GetBooleanValue(dataRow["InheritUseCredSsp"]);
|
||||
connectionInfo.Inheritance.UseEnhancedMode = MiscTools.GetBooleanValue(dataRow["InheritUseEnhancedMode"]);
|
||||
connectionInfo.Inheritance.UseRCG = MiscTools.GetBooleanValue(dataRow["InheritUseRCG"]);
|
||||
connectionInfo.Inheritance.UseRestrictedAdmin = MiscTools.GetBooleanValue(dataRow["InheritUseRestrictedAdmin"]);
|
||||
connectionInfo.Inheritance.UserField = MiscTools.GetBooleanValue(dataRow["InheritUserField"]);
|
||||
connectionInfo.Inheritance.Username = MiscTools.GetBooleanValue(dataRow["InheritUsername"]);
|
||||
connectionInfo.Inheritance.UseVmId = MiscTools.GetBooleanValue(dataRow["InheritUseVmId"]);
|
||||
connectionInfo.Inheritance.VmId = MiscTools.GetBooleanValue(dataRow["InheritVmId"]);
|
||||
connectionInfo.Inheritance.VNCAuthMode = MiscTools.GetBooleanValue(dataRow["InheritVNCAuthMode"]);
|
||||
connectionInfo.Inheritance.VNCColors = MiscTools.GetBooleanValue(dataRow["InheritVNCColors"]);
|
||||
connectionInfo.Inheritance.VNCCompression = MiscTools.GetBooleanValue(dataRow["InheritVNCCompression"]);
|
||||
connectionInfo.Inheritance.VNCEncoding = MiscTools.GetBooleanValue(dataRow["InheritVNCEncoding"]);
|
||||
connectionInfo.Inheritance.VNCProxyIP = MiscTools.GetBooleanValue(dataRow["InheritVNCProxyIP"]);
|
||||
connectionInfo.Inheritance.VNCProxyPassword = MiscTools.GetBooleanValue(dataRow["InheritVNCProxyPassword"]);
|
||||
connectionInfo.Inheritance.VNCProxyPort = MiscTools.GetBooleanValue(dataRow["InheritVNCProxyPort"]);
|
||||
connectionInfo.Inheritance.VNCProxyType = MiscTools.GetBooleanValue(dataRow["InheritVNCProxyType"]);
|
||||
connectionInfo.Inheritance.VNCProxyUsername = MiscTools.GetBooleanValue(dataRow["InheritVNCProxyUsername"]);
|
||||
connectionInfo.Inheritance.VNCSmartSizeMode = MiscTools.GetBooleanValue(dataRow["InheritVNCSmartSizeMode"]);
|
||||
connectionInfo.Inheritance.VNCViewOnly = MiscTools.GetBooleanValue(dataRow["InheritVNCViewOnly"]);
|
||||
}
|
||||
|
||||
private string DecryptValue(string cipherText)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _cryptographyProvider.Decrypt(cipherText, _decryptionKey);
|
||||
}
|
||||
catch (EncryptionException)
|
||||
{
|
||||
// value may not be encrypted
|
||||
return cipherText;
|
||||
}
|
||||
}
|
||||
|
||||
private ConnectionTreeModel CreateNodeHierarchy(List<ConnectionInfo> connectionList, DataTable dataTable)
|
||||
{
|
||||
var connectionTreeModel = new ConnectionTreeModel();
|
||||
var rootNode = new RootNodeInfo(RootNodeType.Connection, "0")
|
||||
{
|
||||
PasswordString = _decryptionKey.ConvertToUnsecureString()
|
||||
};
|
||||
connectionTreeModel.AddRootNode(rootNode);
|
||||
|
||||
foreach (DataRow row in dataTable.Rows)
|
||||
{
|
||||
var id = (string)row["ConstantID"];
|
||||
var connectionInfo = connectionList.First(node => node.ConstantID == id);
|
||||
var parentId = (string)row["ParentID"];
|
||||
if (parentId == "0" || connectionList.All(node => node.ConstantID != parentId))
|
||||
rootNode.AddChild(connectionInfo);
|
||||
else
|
||||
(connectionList.First(node => node.ConstantID == parentId) as ContainerInfo)?.AddChild(connectionInfo);
|
||||
}
|
||||
|
||||
return connectionTreeModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Sql
|
||||
{
|
||||
public class LocalConnectionPropertiesModel
|
||||
{
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Sql
|
||||
{
|
||||
public class LocalConnectionPropertiesXmlSerializer :
|
||||
ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string>,
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Sql
|
||||
{
|
||||
public class SqlConnectionListMetaData
|
||||
{
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Data.Common;
|
||||
using System.Globalization;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Security;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Config.DatabaseConnectors;
|
||||
@@ -11,7 +12,7 @@ using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree.Root;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Sql
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlDatabaseMetaDataRetriever
|
||||
@@ -48,7 +49,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
{
|
||||
Name = dbDataReader["Name"] as string ?? "",
|
||||
Protected = dbDataReader["Protected"] as string ?? "",
|
||||
Export = (bool)dbDataReader["Export"],
|
||||
Export = dbDataReader["Export"].Equals(1),
|
||||
ConfVersion = new Version(Convert.ToString(dbDataReader["confVersion"], CultureInfo.InvariantCulture) ?? string.Empty)
|
||||
};
|
||||
}
|
||||
@@ -68,13 +69,18 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
|
||||
public void WriteDatabaseMetaData(RootNodeInfo rootTreeNode, IDatabaseConnector databaseConnector)
|
||||
{
|
||||
// TODO: use transaction
|
||||
|
||||
var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
|
||||
|
||||
string strProtected;
|
||||
|
||||
if (rootTreeNode != null)
|
||||
{
|
||||
if (rootTreeNode.Password)
|
||||
{
|
||||
var password = rootTreeNode.PasswordString.ConvertToSecureString();
|
||||
SecureString password = rootTreeNode.PasswordString.ConvertToSecureString();
|
||||
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsProtected", password);
|
||||
}
|
||||
else
|
||||
@@ -87,7 +93,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
strProtected = cryptographyProvider.Encrypt("ThisIsNotProtected", Runtime.EncryptionKey);
|
||||
}
|
||||
|
||||
var cmd = databaseConnector.DbCommand("DELETE FROM tblRoot");
|
||||
var cmd = databaseConnector.DbCommand("TRUNCATE TABLE tblRoot");
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
if (rootTreeNode != null)
|
||||
@@ -95,7 +101,8 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
cmd = databaseConnector.DbCommand(
|
||||
"INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES('" +
|
||||
MiscTools.PrepareValueForDB(rootTreeNode.Name) + "', 0, '" + strProtected + "','" +
|
||||
ConnectionsFileInfo.ConnectionFileVersion.ToString() + "')");
|
||||
ConnectionsFileInfo.ConnectionFileVersion + "')");
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
else
|
||||
@@ -112,8 +119,8 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
{
|
||||
// ANSI SQL way. Works in PostgreSQL, MSSQL, MySQL.
|
||||
var cmd = databaseConnector.DbCommand("select case when exists((select * from information_schema.tables where table_name = '" + tableName + "')) then 1 else 0 end");
|
||||
cmd.ExecuteNonQuery();
|
||||
exists = (int)(long)cmd.ExecuteScalar()! == 1;
|
||||
var cmdResult = Convert.ToInt16(cmd.ExecuteScalar());
|
||||
exists = (cmdResult == 1);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -121,7 +128,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
{
|
||||
// Other RDBMS. Graceful degradation
|
||||
exists = true;
|
||||
var cmdOthers = databaseConnector.DbCommand("select 1 from " + tableName + " where 1 = 0");
|
||||
DbCommand cmdOthers = databaseConnector.DbCommand("select 1 from " + tableName + " where 1 = 0");
|
||||
cmdOthers.ExecuteNonQuery();
|
||||
}
|
||||
catch
|
||||
@@ -136,9 +143,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
|
||||
private void InitializeDatabaseSchema(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
string sql;
|
||||
|
||||
var t = databaseConnector.GetType();
|
||||
|
||||
|
||||
if (databaseConnector.GetType() == typeof(MSSqlDatabaseConnector))
|
||||
{
|
||||
sql = @"
|
||||
@@ -204,13 +209,14 @@ CREATE TABLE [dbo].[tblCons] (
|
||||
[RdpVersion] varchar(10) NULL,
|
||||
[RedirectAudioCapture] bit NOT NULL,
|
||||
[RedirectClipboard] bit NOT NULL,
|
||||
[RedirectDiskDrives] bit NOT NULL,
|
||||
[RedirectDiskDrives] varchar(32) DEFAULT NULL,
|
||||
[RedirectDiskDrivesCustom] varchar(32) DEFAULT NULL,
|
||||
[RedirectKeys] bit NOT NULL,
|
||||
[RedirectPorts] bit NOT NULL,
|
||||
[RedirectPrinters] bit NOT NULL,
|
||||
[RedirectSmartCards] bit NOT NULL,
|
||||
[RedirectSound] varchar(64) NOT NULL,
|
||||
[RenderingEngine] varchar(16) NULL,
|
||||
[RenderingEngine] varchar(32) NULL,
|
||||
[Resolution] varchar(32) NOT NULL,
|
||||
[SSHOptions] varchar(1024) NOT NULL,
|
||||
[SSHTunnelConnectionName] varchar(128) NOT NULL,
|
||||
@@ -275,6 +281,7 @@ CREATE TABLE [dbo].[tblCons] (
|
||||
[InheritRedirectAudioCapture] bit NOT NULL,
|
||||
[InheritRedirectClipboard] bit NOT NULL,
|
||||
[InheritRedirectDiskDrives] bit NOT NULL,
|
||||
[InheritRedirectDiskDrivesCustom] bit NOT NULL,
|
||||
[InheritRedirectKeys] bit NOT NULL,
|
||||
[InheritRedirectPorts] bit NOT NULL,
|
||||
[InheritRedirectPrinters] bit NOT NULL,
|
||||
@@ -358,24 +365,24 @@ CREATE TABLE `tblCons` (
|
||||
`LastChange` datetime NOT NULL,
|
||||
`Name` varchar(128) NOT NULL,
|
||||
`Type` varchar(32) NOT NULL,
|
||||
`Expanded` tinyint(1) NOT NULL,
|
||||
`AutomaticResize` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`CacheBitmaps` tinyint(1) NOT NULL,
|
||||
`Expanded` tinyint NOT NULL,
|
||||
`AutomaticResize` tinyint NOT NULL DEFAULT 1,
|
||||
`CacheBitmaps` tinyint NOT NULL,
|
||||
`Colors` varchar(32) NOT NULL,
|
||||
`ConnectToConsole` tinyint(1) NOT NULL,
|
||||
`Connected` tinyint(1) NOT NULL,
|
||||
`ConnectToConsole` tinyint NOT NULL,
|
||||
`Connected` tinyint NOT NULL,
|
||||
`Description` varchar(1024) DEFAULT NULL,
|
||||
`DisableCursorBlinking` tinyint(1) NOT NULL,
|
||||
`DisableCursorShadow` tinyint(1) NOT NULL,
|
||||
`DisableFullWindowDrag` tinyint(1) NOT NULL,
|
||||
`DisableMenuAnimations` tinyint(1) NOT NULL,
|
||||
`DisplayThemes` tinyint(1) NOT NULL,
|
||||
`DisplayWallpaper` tinyint(1) NOT NULL,
|
||||
`DisableCursorBlinking` tinyint NOT NULL,
|
||||
`DisableCursorShadow` tinyint NOT NULL,
|
||||
`DisableFullWindowDrag` tinyint NOT NULL,
|
||||
`DisableMenuAnimations` tinyint NOT NULL,
|
||||
`DisplayThemes` tinyint NOT NULL,
|
||||
`DisplayWallpaper` tinyint NOT NULL,
|
||||
`Domain` varchar(512) DEFAULT NULL,
|
||||
`EnableDesktopComposition` tinyint(1) NOT NULL,
|
||||
`EnableFontSmoothing` tinyint(1) NOT NULL,
|
||||
`EnableDesktopComposition` tinyint NOT NULL,
|
||||
`EnableFontSmoothing` tinyint NOT NULL,
|
||||
`ExtApp` varchar(256) DEFAULT NULL,
|
||||
`Favorite` tinyint(1) NOT NULL,
|
||||
`Favorite` tinyint NOT NULL,
|
||||
`Hostname` varchar(512) DEFAULT NULL,
|
||||
`Icon` varchar(128) NOT NULL,
|
||||
`LoadBalanceInfo` varchar(1024) DEFAULT NULL,
|
||||
@@ -394,26 +401,27 @@ CREATE TABLE `tblCons` (
|
||||
`RDGatewayUsageMethod` varchar(32) NOT NULL,
|
||||
`RDGatewayUseConnectionCredentials` varchar(32) NOT NULL,
|
||||
`RDGatewayUsername` varchar(512) DEFAULT NULL,
|
||||
`RDPAlertIdleTimeout` tinyint(1) NOT NULL,
|
||||
`RDPAlertIdleTimeout` tinyint NOT NULL,
|
||||
`RDPAuthenticationLevel` varchar(32) NOT NULL,
|
||||
`RDPMinutesToIdleTimeout` int(11) NOT NULL,
|
||||
`RdpVersion` varchar(10) DEFAULT NULL,
|
||||
`RedirectAudioCapture` tinyint(1) NOT NULL,
|
||||
`RedirectClipboard` tinyint(1) NOT NULL,
|
||||
`RedirectDiskDrives` tinyint(1) NOT NULL,
|
||||
`RedirectKeys` tinyint(1) NOT NULL,
|
||||
`RedirectPorts` tinyint(1) NOT NULL,
|
||||
`RedirectPrinters` tinyint(1) NOT NULL,
|
||||
`RedirectSmartCards` tinyint(1) NOT NULL,
|
||||
`RedirectAudioCapture` tinyint NOT NULL,
|
||||
`RedirectClipboard` tinyint NOT NULL,
|
||||
`RedirectDiskDrives` varchar(32) DEFAULT NULL,
|
||||
`RedirectDiskDrivesCustom` varchar(32) DEFAULT NULL,
|
||||
`RedirectKeys` tinyint NOT NULL,
|
||||
`RedirectPorts` tinyint NOT NULL,
|
||||
`RedirectPrinters` tinyint NOT NULL,
|
||||
`RedirectSmartCards` tinyint NOT NULL,
|
||||
`RedirectSound` varchar(64) NOT NULL,
|
||||
`RenderingEngine` varchar(16) DEFAULT NULL,
|
||||
`RenderingEngine` varchar(32) DEFAULT NULL,
|
||||
`Resolution` varchar(32) NOT NULL,
|
||||
`SSHOptions` varchar(1024) NOT NULL,
|
||||
`SSHTunnelConnectionName` varchar(128) NOT NULL,
|
||||
`SoundQuality` varchar(20) NOT NULL,
|
||||
`UseCredSsp` tinyint(1) NOT NULL,
|
||||
`UseEnhancedMode` tinyint(1) NOT NULL,
|
||||
`UseVmId` tinyint(1) NOT NULL,
|
||||
`UseCredSsp` tinyint NOT NULL,
|
||||
`UseEnhancedMode` tinyint NOT NULL,
|
||||
`UseVmId` tinyint NOT NULL,
|
||||
`UserField` varchar(256) DEFAULT NULL,
|
||||
`Username` varchar(512) DEFAULT NULL,
|
||||
`VNCAuthMode` varchar(10) DEFAULT NULL,
|
||||
@@ -426,85 +434,86 @@ CREATE TABLE `tblCons` (
|
||||
`VNCProxyType` varchar(20) DEFAULT NULL,
|
||||
`VNCProxyUsername` varchar(512) DEFAULT NULL,
|
||||
`VNCSmartSizeMode` varchar(20) DEFAULT NULL,
|
||||
`VNCViewOnly` tinyint(1) NOT NULL,
|
||||
`VNCViewOnly` tinyint NOT NULL,
|
||||
`VmId` varchar(512) DEFAULT NULL,
|
||||
`ICAEncryptionStrength` varchar(32) NOT NULL,
|
||||
`InheritAutomaticResize` tinyint(1) NOT NULL,
|
||||
`InheritCacheBitmaps` tinyint(1) NOT NULL,
|
||||
`InheritColors` tinyint(1) NOT NULL,
|
||||
`InheritDescription` tinyint(1) NOT NULL,
|
||||
`InheritDisableCursorBlinking` tinyint(1) NOT NULL,
|
||||
`InheritDisableCursorShadow` tinyint(1) NOT NULL,
|
||||
`InheritDisableFullWindowDrag` tinyint(1) NOT NULL,
|
||||
`InheritDisableMenuAnimations` tinyint(1) NOT NULL,
|
||||
`InheritDisplayThemes` tinyint(1) NOT NULL,
|
||||
`InheritDisplayWallpaper` tinyint(1) NOT NULL,
|
||||
`InheritDomain` tinyint(1) NOT NULL,
|
||||
`InheritEnableDesktopComposition` tinyint(1) NOT NULL,
|
||||
`InheritEnableFontSmoothing` tinyint(1) NOT NULL,
|
||||
`InheritExtApp` tinyint(1) NOT NULL,
|
||||
`InheritFavorite` tinyint(1) NOT NULL,
|
||||
`InheritICAEncryptionStrength` tinyint(1) NOT NULL,
|
||||
`InheritIcon` tinyint(1) NOT NULL,
|
||||
`InheritLoadBalanceInfo` tinyint(1) NOT NULL,
|
||||
`InheritMacAddress` tinyint(1) NOT NULL,
|
||||
`InheritOpeningCommand` tinyint(1) NOT NULL,
|
||||
`InheritPanel` tinyint(1) NOT NULL,
|
||||
`InheritPassword` tinyint(1) NOT NULL,
|
||||
`InheritPort` tinyint(1) NOT NULL,
|
||||
`InheritPostExtApp` tinyint(1) NOT NULL,
|
||||
`InheritPreExtApp` tinyint(1) NOT NULL,
|
||||
`InheritProtocol` tinyint(1) NOT NULL,
|
||||
`InheritPuttySession` tinyint(1) NOT NULL,
|
||||
`InheritRDGatewayDomain` tinyint(1) NOT NULL,
|
||||
`InheritRDGatewayHostname` tinyint(1) NOT NULL,
|
||||
`InheritRDGatewayPassword` tinyint(1) NOT NULL,
|
||||
`InheritRDGatewayUsageMethod` tinyint(1) NOT NULL,
|
||||
`InheritRDGatewayUseConnectionCredentials` tinyint(1) NOT NULL,
|
||||
`InheritRDGatewayExternalCredentialProvider` tinyint(1) NOT NULL,
|
||||
`InheritRDGatewayUsername` tinyint(1) NOT NULL,
|
||||
`InheritRDGatewayUserViaAPI` tinyint(1) NOT NULL,
|
||||
`InheritRDPAlertIdleTimeout` tinyint(1) NOT NULL,
|
||||
`InheritRDPAuthenticationLevel` tinyint(1) NOT NULL,
|
||||
`InheritRDPMinutesToIdleTimeout` tinyint(1) NOT NULL,
|
||||
`InheritRdpVersion` tinyint(1) NOT NULL,
|
||||
`InheritRedirectAudioCapture` tinyint(1) NOT NULL,
|
||||
`InheritRedirectClipboard` tinyint(1) NOT NULL,
|
||||
`InheritRedirectDiskDrives` tinyint(1) NOT NULL,
|
||||
`InheritRedirectKeys` tinyint(1) NOT NULL,
|
||||
`InheritRedirectPorts` tinyint(1) NOT NULL,
|
||||
`InheritRedirectPrinters` tinyint(1) NOT NULL,
|
||||
`InheritRedirectSmartCards` tinyint(1) NOT NULL,
|
||||
`InheritRedirectSound` tinyint(1) NOT NULL,
|
||||
`InheritRenderingEngine` tinyint(1) NOT NULL,
|
||||
`InheritResolution` tinyint(1) NOT NULL,
|
||||
`InheritSSHOptions` tinyint(1) NOT NULL,
|
||||
`InheritSSHTunnelConnectionName` tinyint(1) NOT NULL,
|
||||
`InheritSoundQuality` tinyint(1) NOT NULL,
|
||||
`InheritUseConsoleSession` tinyint(1) NOT NULL,
|
||||
`InheritUseCredSsp` tinyint(1) NOT NULL,
|
||||
`InheritUseRestrictedAdmin` tinyint(1) NOT NULL,
|
||||
`InheritUseRCG` tinyint(1) NOT NULL,
|
||||
`InheritExternalCredentialProvider` tinyint(1) NOT NULL,
|
||||
`InheritUserViaAPI` tinyint(1) NOT NULL,
|
||||
`UseRestrictedAdmin` tinyint(1) NOT NULL,
|
||||
`UseRCG` tinyint(1) NOT NULL,
|
||||
`InheritUseEnhancedMode` tinyint(1) DEFAULT NULL,
|
||||
`InheritUseVmId` tinyint(1) DEFAULT NULL,
|
||||
`InheritUserField` tinyint(1) NOT NULL,
|
||||
`InheritUsername` tinyint(1) NOT NULL,
|
||||
`InheritVNCAuthMode` tinyint(1) NOT NULL,
|
||||
`InheritVNCColors` tinyint(1) NOT NULL,
|
||||
`InheritVNCCompression` tinyint(1) NOT NULL,
|
||||
`InheritVNCEncoding` tinyint(1) NOT NULL,
|
||||
`InheritVNCProxyIP` tinyint(1) NOT NULL,
|
||||
`InheritVNCProxyPassword` tinyint(1) NOT NULL,
|
||||
`InheritVNCProxyPort` tinyint(1) NOT NULL,
|
||||
`InheritVNCProxyType` tinyint(1) NOT NULL,
|
||||
`InheritVNCProxyUsername` tinyint(1) NOT NULL,
|
||||
`InheritVNCSmartSizeMode` tinyint(1) NOT NULL,
|
||||
`InheritVNCViewOnly` tinyint(1) NOT NULL,
|
||||
`InheritVmId` tinyint(1) NOT NULL,
|
||||
`InheritAutomaticResize` tinyint NOT NULL,
|
||||
`InheritCacheBitmaps` tinyint NOT NULL,
|
||||
`InheritColors` tinyint NOT NULL,
|
||||
`InheritDescription` tinyint NOT NULL,
|
||||
`InheritDisableCursorBlinking` tinyint NOT NULL,
|
||||
`InheritDisableCursorShadow` tinyint NOT NULL,
|
||||
`InheritDisableFullWindowDrag` tinyint NOT NULL,
|
||||
`InheritDisableMenuAnimations` tinyint NOT NULL,
|
||||
`InheritDisplayThemes` tinyint NOT NULL,
|
||||
`InheritDisplayWallpaper` tinyint NOT NULL,
|
||||
`InheritDomain` tinyint NOT NULL,
|
||||
`InheritEnableDesktopComposition` tinyint NOT NULL,
|
||||
`InheritEnableFontSmoothing` tinyint NOT NULL,
|
||||
`InheritExtApp` tinyint NOT NULL,
|
||||
`InheritFavorite` tinyint NOT NULL,
|
||||
`InheritICAEncryptionStrength` tinyint NOT NULL,
|
||||
`InheritIcon` tinyint NOT NULL,
|
||||
`InheritLoadBalanceInfo` tinyint NOT NULL,
|
||||
`InheritMacAddress` tinyint NOT NULL,
|
||||
`InheritOpeningCommand` tinyint NOT NULL,
|
||||
`InheritPanel` tinyint NOT NULL,
|
||||
`InheritPassword` tinyint NOT NULL,
|
||||
`InheritPort` tinyint NOT NULL,
|
||||
`InheritPostExtApp` tinyint NOT NULL,
|
||||
`InheritPreExtApp` tinyint NOT NULL,
|
||||
`InheritProtocol` tinyint NOT NULL,
|
||||
`InheritPuttySession` tinyint NOT NULL,
|
||||
`InheritRDGatewayDomain` tinyint NOT NULL,
|
||||
`InheritRDGatewayHostname` tinyint NOT NULL,
|
||||
`InheritRDGatewayPassword` tinyint NOT NULL,
|
||||
`InheritRDGatewayUsageMethod` tinyint NOT NULL,
|
||||
`InheritRDGatewayUseConnectionCredentials` tinyint NOT NULL,
|
||||
`InheritRDGatewayExternalCredentialProvider` tinyint NOT NULL,
|
||||
`InheritRDGatewayUsername` tinyint NOT NULL,
|
||||
`InheritRDGatewayUserViaAPI` tinyint NOT NULL,
|
||||
`InheritRDPAlertIdleTimeout` tinyint NOT NULL,
|
||||
`InheritRDPAuthenticationLevel` tinyint NOT NULL,
|
||||
`InheritRDPMinutesToIdleTimeout` tinyint NOT NULL,
|
||||
`InheritRdpVersion` tinyint NOT NULL,
|
||||
`InheritRedirectAudioCapture` tinyint NOT NULL,
|
||||
`InheritRedirectClipboard` tinyint NOT NULL,
|
||||
`InheritRedirectDiskDrives` tinyint NOT NULL,
|
||||
`InheritRedirectDiskDrivesCustom` tinyint NOT NULL,
|
||||
`InheritRedirectKeys` tinyint NOT NULL,
|
||||
`InheritRedirectPorts` tinyint NOT NULL,
|
||||
`InheritRedirectPrinters` tinyint NOT NULL,
|
||||
`InheritRedirectSmartCards` tinyint NOT NULL,
|
||||
`InheritRedirectSound` tinyint NOT NULL,
|
||||
`InheritRenderingEngine` tinyint NOT NULL,
|
||||
`InheritResolution` tinyint NOT NULL,
|
||||
`InheritSSHOptions` tinyint NOT NULL,
|
||||
`InheritSSHTunnelConnectionName` tinyint NOT NULL,
|
||||
`InheritSoundQuality` tinyint NOT NULL,
|
||||
`InheritUseConsoleSession` tinyint NOT NULL,
|
||||
`InheritUseCredSsp` tinyint NOT NULL,
|
||||
`InheritUseRestrictedAdmin` tinyint NOT NULL,
|
||||
`InheritUseRCG` tinyint NOT NULL,
|
||||
`InheritExternalCredentialProvider` tinyint NOT NULL,
|
||||
`InheritUserViaAPI` tinyint NOT NULL,
|
||||
`UseRestrictedAdmin` tinyint NOT NULL,
|
||||
`UseRCG` tinyint NOT NULL,
|
||||
`InheritUseEnhancedMode` tinyint DEFAULT NULL,
|
||||
`InheritUseVmId` tinyint DEFAULT NULL,
|
||||
`InheritUserField` tinyint NOT NULL,
|
||||
`InheritUsername` tinyint NOT NULL,
|
||||
`InheritVNCAuthMode` tinyint NOT NULL,
|
||||
`InheritVNCColors` tinyint NOT NULL,
|
||||
`InheritVNCCompression` tinyint NOT NULL,
|
||||
`InheritVNCEncoding` tinyint NOT NULL,
|
||||
`InheritVNCProxyIP` tinyint NOT NULL,
|
||||
`InheritVNCProxyPassword` tinyint NOT NULL,
|
||||
`InheritVNCProxyPort` tinyint NOT NULL,
|
||||
`InheritVNCProxyType` tinyint NOT NULL,
|
||||
`InheritVNCProxyUsername` tinyint NOT NULL,
|
||||
`InheritVNCSmartSizeMode` tinyint NOT NULL,
|
||||
`InheritVNCViewOnly` tinyint NOT NULL,
|
||||
`InheritVmId` tinyint NOT NULL,
|
||||
`StartProgram` varchar(512) DEFAULT NULL,
|
||||
`StartProgramWorkDir` varchar(512) DEFAULT NULL,
|
||||
`EC2Region` varchar(32) DEFAULT NULL,
|
||||
@@ -526,7 +535,7 @@ DROP TABLE IF EXISTS `tblRoot`;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `tblRoot` (
|
||||
`Name` varchar(2048) NOT NULL,
|
||||
`Export` tinyint(1) NOT NULL,
|
||||
`Export` tinyint NOT NULL,
|
||||
`Protected` varchar(4048) NOT NULL,
|
||||
`ConfVersion` varchar(15) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
@@ -555,6 +564,227 @@ CREATE TABLE `tblUpdate` (
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// sql = @"
|
||||
///*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
///*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
///*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
///*!40101 SET NAMES utf8 */;
|
||||
///*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
///*!40103 SET TIME_ZONE='+00:00' */;
|
||||
///*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
///*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
///*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
///*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
//--
|
||||
//-- Table structure for table `tblCons`
|
||||
//--
|
||||
|
||||
//DROP TABLE IF EXISTS `tblCons`;
|
||||
///*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
///*!40101 SET character_set_client = utf8 */;
|
||||
//CREATE TABLE `tblCons` (
|
||||
// `ID` int(11) NOT NULL AUTO_INCREMENT,
|
||||
// `ConstantID` varchar(128) NOT NULL,
|
||||
// `PositionID` int(11) NOT NULL,
|
||||
// `ParentID` varchar(128) DEFAULT NULL,
|
||||
// `LastChange` datetime NOT NULL,
|
||||
// `Name` varchar(128) NOT NULL,
|
||||
// `Type` varchar(32) NOT NULL,
|
||||
// `Expanded` tinyint NOT NULL,
|
||||
// `AutomaticResize` tinyint NOT NULL DEFAULT 1,
|
||||
// `CacheBitmaps` tinyint NOT NULL,
|
||||
// `Colors` varchar(32) NOT NULL,
|
||||
// `ConnectToConsole` tinyint NOT NULL,
|
||||
// `Connected` tinyint NOT NULL,
|
||||
// `Description` varchar(1024) DEFAULT NULL,
|
||||
// `DisableCursorBlinking` tinyint NOT NULL,
|
||||
// `DisableCursorShadow` tinyint NOT NULL,
|
||||
// `DisableFullWindowDrag` tinyint NOT NULL,
|
||||
// `DisableMenuAnimations` tinyint NOT NULL,
|
||||
// `DisplayThemes` tinyint NOT NULL,
|
||||
// `DisplayWallpaper` tinyint NOT NULL,
|
||||
// `Domain` varchar(512) DEFAULT NULL,
|
||||
// `EnableDesktopComposition` tinyint NOT NULL,
|
||||
// `EnableFontSmoothing` tinyint NOT NULL,
|
||||
// `ExtApp` varchar(256) DEFAULT NULL,
|
||||
// `Favorite` tinyint NOT NULL,
|
||||
// `Hostname` varchar(512) DEFAULT NULL,
|
||||
// `LoadBalanceInfo` varchar(1024) DEFAULT NULL,
|
||||
// `MacAddress` varchar(32) DEFAULT NULL,
|
||||
// `Panel` varchar(128) NOT NULL,
|
||||
// `Password` varchar(1024) DEFAULT NULL,
|
||||
// `Port` int(11) NOT NULL,
|
||||
// `PostExtApp` varchar(256) DEFAULT NULL,
|
||||
// `PreExtApp` varchar(256) DEFAULT NULL,
|
||||
// `Protocol` varchar(32) NOT NULL,
|
||||
// `PuttySession` varchar(128) DEFAULT NULL,
|
||||
// `RDGatewayDomain` varchar(512) DEFAULT NULL,
|
||||
// `RDGatewayHostname` varchar(512) DEFAULT NULL,
|
||||
// `RDGatewayPassword` varchar(1024) DEFAULT NULL,
|
||||
// `RDGatewayUsageMethod` varchar(32) NOT NULL,
|
||||
// `RDGatewayUseConnectionCredentials` varchar(32) NOT NULL,
|
||||
// `RDGatewayUsername` varchar(512) DEFAULT NULL,
|
||||
// `RDPAlertIdleTimeout` tinyint NOT NULL,
|
||||
// `RDPAuthenticationLevel` varchar(32) NOT NULL,
|
||||
// `RDPMinutesToIdleTimeout` int(11) NOT NULL,
|
||||
// `RdpVersion` varchar(10) DEFAULT NULL,
|
||||
// `RedirectAudioCapture` tinyint NOT NULL,
|
||||
// `RedirectClipboard` tinyint NOT NULL DEFAULT 0,
|
||||
// `RedirectDiskDrives` tinyint NOT NULL,
|
||||
// `RedirectKeys` tinyint NOT NULL,
|
||||
// `RedirectPorts` tinyint NOT NULL,
|
||||
// `RedirectPrinters` tinyint NOT NULL,
|
||||
// `RedirectSmartCards` tinyint NOT NULL,
|
||||
// `RedirectSound` varchar(64) NOT NULL,
|
||||
// `RenderingEngine` varchar(10) DEFAULT NULL,
|
||||
// `Resolution` varchar(32) NOT NULL,
|
||||
// `SSHOptions` varchar(1024) NOT NULL,
|
||||
// `SSHTunnelConnectionName` varchar(128) NOT NULL,
|
||||
// `SoundQuality` varchar(20) NOT NULL,
|
||||
// `UseCredSsp` tinyint NOT NULL,
|
||||
// `UseEnhancedMode` tinyint DEFAULT NULL,
|
||||
// `UseVmId` tinyint DEFAULT NULL,
|
||||
// `UserField` varchar(256) DEFAULT NULL,
|
||||
// `Username` varchar(512) DEFAULT NULL,
|
||||
// `VNCAuthMode` varchar(10) DEFAULT NULL,
|
||||
// `VNCColors` varchar(10) DEFAULT NULL,
|
||||
// `VNCCompression` varchar(10) DEFAULT NULL,
|
||||
// `VNCEncoding` varchar(20) DEFAULT NULL,
|
||||
// `VNCProxyIP` varchar(128) DEFAULT NULL,
|
||||
// `VNCProxyPassword` varchar(1024) DEFAULT NULL,
|
||||
// `VNCProxyPort` int(11) DEFAULT NULL,
|
||||
// `VNCProxyType` varchar(20) DEFAULT NULL,
|
||||
// `VNCProxyUsername` varchar(512) DEFAULT NULL,
|
||||
// `VNCSmartSizeMode` varchar(20) DEFAULT NULL,
|
||||
// `VNCViewOnly` tinyint NOT NULL,
|
||||
// `VmId` varchar(512) DEFAULT NULL,
|
||||
// `ICAEncryptionStrength` varchar(32) NOT NULL,
|
||||
// `Icon` varchar(128) NOT NULL,
|
||||
// `InheritAutomaticResize` tinyint NOT NULL DEFAULT 0,
|
||||
// `InheritCacheBitmaps` tinyint NOT NULL,
|
||||
// `InheritColors` tinyint NOT NULL,
|
||||
// `InheritDescription` tinyint NOT NULL,
|
||||
// `InheritDisableCursorBlinking` tinyint NOT NULL,
|
||||
// `InheritDisableCursorShadow` tinyint NOT NULL,
|
||||
// `InheritDisableFullWindowDrag` tinyint NOT NULL,
|
||||
// `InheritDisableMenuAnimations` tinyint NOT NULL,
|
||||
// `InheritDisplayThemes` tinyint NOT NULL,
|
||||
// `InheritDisplayWallpaper` tinyint NOT NULL,
|
||||
// `InheritDomain` tinyint NOT NULL,
|
||||
// `InheritEnableDesktopComposition` tinyint NOT NULL,
|
||||
// `InheritEnableFontSmoothing` tinyint NOT NULL,
|
||||
// `InheritExtApp` tinyint NOT NULL,
|
||||
// `InheritFavorite` tinyint NOT NULL,
|
||||
// `InheritICAEncryptionStrength` tinyint NOT NULL,
|
||||
// `InheritIcon` tinyint NOT NULL,
|
||||
// `InheritLoadBalanceInfo` tinyint NOT NULL DEFAULT 0,
|
||||
// `InheritMacAddress` tinyint NOT NULL,
|
||||
// `InheritPanel` tinyint NOT NULL,
|
||||
// `InheritPassword` tinyint NOT NULL,
|
||||
// `InheritPort` tinyint NOT NULL,
|
||||
// `InheritPostExtApp` tinyint NOT NULL,
|
||||
// `InheritPreExtApp` tinyint NOT NULL,
|
||||
// `InheritProtocol` tinyint NOT NULL,
|
||||
// `InheritPuttySession` tinyint NOT NULL,
|
||||
// `InheritRDGatewayDomain` tinyint NOT NULL,
|
||||
// `InheritRDGatewayHostname` tinyint NOT NULL,
|
||||
// `InheritRDGatewayPassword` tinyint NOT NULL,
|
||||
// `InheritRDGatewayUsageMethod` tinyint NOT NULL,
|
||||
// `InheritRDGatewayUseConnectionCredentials` tinyint NOT NULL,
|
||||
// `InheritRDGatewayUsername` tinyint NOT NULL,
|
||||
// `InheritRDPAlertIdleTimeout` tinyint NOT NULL,
|
||||
// `InheritRDPAuthenticationLevel` tinyint NOT NULL,
|
||||
// `InheritRDPMinutesToIdleTimeout` tinyint NOT NULL,
|
||||
// `InheritRdpVersion` tinyint NOT NULL DEFAULT 0,
|
||||
// `InheritRedirectAudioCapture` tinyint NOT NULL,
|
||||
// `InheritRedirectClipboard` tinyint NOT NULL DEFAULT 0,
|
||||
// `InheritRedirectDiskDrives` tinyint NOT NULL,
|
||||
// `InheritRedirectKeys` tinyint NOT NULL,
|
||||
// `InheritRedirectPorts` tinyint NOT NULL,
|
||||
// `InheritRedirectPrinters` tinyint NOT NULL,
|
||||
// `InheritRedirectSmartCards` tinyint NOT NULL,
|
||||
// `InheritRedirectSound` tinyint NOT NULL,
|
||||
// `InheritRenderingEngine` tinyint NOT NULL,
|
||||
// `InheritResolution` tinyint NOT NULL,
|
||||
// `InheritSSHOptions` tinyint NOT NULL,
|
||||
// `InheritSSHTunnelConnectionName` tinyint NOT NULL,
|
||||
// `InheritSoundQuality` tinyint NOT NULL,
|
||||
// `InheritUseConsoleSession` tinyint NOT NULL,
|
||||
// `InheritUseCredSsp` tinyint NOT NULL,
|
||||
// `InheritUseEnhancedMode` tinyint DEFAULT NULL,
|
||||
// `InheritUseVmId` tinyint DEFAULT NULL,
|
||||
// `InheritUserField` tinyint NOT NULL,
|
||||
// `InheritUsername` tinyint NOT NULL,
|
||||
// `InheritVNCAuthMode` tinyint NOT NULL,
|
||||
// `InheritVNCColors` tinyint NOT NULL,
|
||||
// `InheritVNCCompression` tinyint NOT NULL,
|
||||
// `InheritVNCEncoding` tinyint NOT NULL,
|
||||
// `InheritVNCProxyIP` tinyint NOT NULL,
|
||||
// `InheritVNCProxyPassword` tinyint NOT NULL,
|
||||
// `InheritVNCProxyPort` tinyint NOT NULL,
|
||||
// `InheritVNCProxyType` tinyint NOT NULL,
|
||||
// `InheritVNCProxyUsername` tinyint NOT NULL,
|
||||
// `InheritVNCSmartSizeMode` tinyint NOT NULL,
|
||||
// `InheritVNCViewOnly` tinyint NOT NULL,
|
||||
// `InheritVmId` tinyint DEFAULT NULL,
|
||||
// PRIMARY KEY (`ConstantID`),
|
||||
// UNIQUE (`ID`)
|
||||
//) ENGINE=InnoDB AUTO_INCREMENT=3324 DEFAULT CHARSET=latin1;
|
||||
///*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
//--
|
||||
//-- Table structure for table `tblRoot`
|
||||
//--
|
||||
|
||||
//DROP TABLE IF EXISTS `tblRoot`;
|
||||
///*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
///*!40101 SET character_set_client = utf8 */;
|
||||
//CREATE TABLE `tblRoot` (
|
||||
// `Name` varchar(2048) NOT NULL,
|
||||
// `Export` tinyint NOT NULL,
|
||||
// `Protected` varchar(4048) NOT NULL,
|
||||
// `ConfVersion` double NOT NULL
|
||||
//) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
///*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
//--
|
||||
//-- Table structure for table `tblUpdate`
|
||||
//--
|
||||
|
||||
//DROP TABLE IF EXISTS `tblUpdate`;
|
||||
///*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
///*!40101 SET character_set_client = utf8 */;
|
||||
//CREATE TABLE `tblUpdate` (
|
||||
// `LastUpdate` datetime(3) DEFAULT NULL
|
||||
//) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
///*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
||||
///*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
///*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
///*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
///*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
///*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
///*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
///*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
///*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
//";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -567,7 +797,3 @@ CREATE TABLE `tblUpdate` (
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//// MySql.Data.MySqlClient.MySqlException: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(`ConstantID`),
|
||||
//UNIQUE(`ID`)
|
||||
// ) ENGINE = InnoDB AUTO_INCREMENT = 3324 DEFAULT ' at line 156'
|
||||
Reference in New Issue
Block a user