コード例 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Credentials EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCredentials(Credentials credentials)
 {
     base.AddObject("Credentials", credentials);
 }
コード例 #2
0
 /// <summary>
 /// Create a new Credentials object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Credentials CreateCredentials(global::System.Int32 id, global::System.String name)
 {
     Credentials credentials = new Credentials();
     credentials.Id = id;
     credentials.Name = name;
     return credentials;
 }
コード例 #3
0
        public static Connections ToConnection(this FavoriteConfigurationElement favorite, TerminalsObjectContext dc, Connections connection = null)
        {
            // Id won't either be changed or set.
            if (connection == null)
                connection = new Connections();

            connection.Name = favorite.Name;
            connection.Notes = favorite.Notes;
            connection.Protocol = favorite.Protocol;

            #region Tags
            connection.Groups.Clear();

            foreach (string tag in favorite.TagList)
            {
                Groups group = dc.Groups.Where(g => g.Name.ToLower() == tag.ToLower()).FirstOrDefault();

                if (group == null)
                {
                    group = new Groups() { Name = tag };
                }

                bool contains = false;
                foreach (Groups availableGroup in connection.Groups)
                {
                    if (availableGroup.Name.ToLower() == tag.ToLower())
                    {
                        contains = true;
                        break;
                    }
                }

                if (!contains)
                {
                   connection.Groups.Add(group);
                }
            }
            #endregion

            #region Credentials
            try
            {
                User user = GetMyUser(dc);

                if (user != null)
                {
                    Credentials credential = dc.Credentials.Where(x => x.Name.ToUpper() == favorite.XmlCredentialSetName.ToUpper() && x.UserId == user.Id).FirstOrDefault();

                    if (credential == null)
                    {
                        credential = new Credentials()
                        {
                            Name = favorite.XmlCredentialSetName,
                            DomainName = favorite.DomainName,
                            UserName = favorite.UserName,
                            Password = favorite.Password,
                            UserId = user.Id
                        };

                        dc.Credentials.AddObject(credential);
                        dc.SaveChanges();
                    }

                    // Get all the user's credentials
                    int[] credentialIds = dc.Credentials.Where(x=> x.UserId == user.Id).Select(x => x.Id).ToArray();
                    
                    // If there's more than one ...
                    if (credentialIds.Length > 0)
                    {
                        // check if there's a specific credentialId
                        int credentialId = dc.Credentials.Where(x => credentialIds.Contains(x.Id) && x.Connections.Contains(connection)).Select(x => x.Id).FirstOrDefault();
                        
                        // if yes update it
                        if (credentialId > 0)
                        {
                            // Find the lookup that
                            // contains the credential id for the
                            // specific connection and update it
                            Credentials lookup = dc.Credentials.Where(x => x.Connections.Contains(connection) && x.Id == credentialId).FirstOrDefault();

                            if (lookup == null)
                            {
                                dc.ExecuteStoreCommand("INSERT INTO CredentialLookup (ConnectionId, CredentialId) VALUES (" + connection.Id + ", " + credential.Id + ")", null);
                         
                                /*
                                lookup = new CredentialLookup()
                                {
                                    ConnectionId = connection.Id,
                                    CredentialId = credential.Id
                                };

                                dc.CredentialLookups.InsertOnSubmit(lookup);
                                dc.SubmitChanges();
                                */
                            }
                            else
                            {
                                dc.ExecuteStoreCommand("UPDATE CredentialLookup SET CredentialId = " + credential.Id + " WHERE CredentialId = " + credentialId + " AND ConnectionId = " + connection.Id, null);
                                
                                //lookup.CredentialId = credential.Id;
                            }
                        }
                        else
                        // create a new one
                        {
                            dc.ExecuteStoreCommand("INSERT INTO CredentialLookup (ConnectionId, CredentialId) VALUES (" + connection.Id + ", " + credential.Id + ")", null);
                         
                            /*
                            CredentialLookup lookup = new CredentialLookup()
                            {
                                ConnectionId = connection.Id,
                                CredentialId = credential.Id
                            };

                            dc.CredentialLookups.InsertOnSubmit(lookup);
                            dc.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict);
                            */
                        }

                    }
                    else
                    {
                        dc.ExecuteStoreCommand("INSERT INTO CredentialLookup (ConnectionId, CredentialId) VALUES (" + connection.Id + ", " + credential.Id + ")", null);
                         
                        /*
                        CredentialLookup lookup = new CredentialLookup()
                            {
                                ConnectionId = connection.Id,
                                CredentialId = credential.Id
                            };

                        dc.CredentialLookups.InsertOnSubmit(lookup);
                        dc.SubmitChanges();*/
                    }
                }
            }
            catch
            {
                Kohl.Framework.Logging.Log.Error("Error setting credential for connection in database.");
            }
            #endregion

            //connection.ToolBarIcon = favorite.ToolBarIcon;

            connection.ServerName = favorite.ServerName;
            connection.NewWindow = favorite.NewWindow;
            connection.Port = favorite.Port;
            connection.DesktopSizeHeight = favorite.DesktopSizeHeight;
            connection.DesktopSizeWidth = favorite.DesktopSizeWidth;
            connection.DesktopSize = (int)favorite.DesktopSize;
            connection.ExecuteBeforeConnect = favorite.ExecuteBeforeConnect;
            connection.ExecuteBeforeConnectCommand = favorite.ExecuteBeforeConnectCommand;
            connection.ExecuteBeforeConnectArgs = favorite.ExecuteBeforeConnectArgs;
            connection.ExecuteBeforeConnectInitialDirectory = favorite.ExecuteBeforeConnectInitialDirectory;
            connection.ExecuteBeforeConnectWaitForExit = favorite.ExecuteBeforeConnectWaitForExit;
            connection.ExplorerStyle = favorite.ExplorerStyle;
            connection.ExplorerDirectory = favorite.ExplorerDirectory;
            connection.ExplorerDirectoryDual = favorite.ExplorerDirectoryDual;
            connection.ExplorerDirectoryTripple = favorite.ExplorerDirectoryTripple;
            connection.ExplorerDirectoryQuad = favorite.ExplorerDirectoryQuad;
            connection.HtmlFormFieldsString = favorite.HtmlFormFieldsString;
            connection.BrowserAuthentication = (int)favorite.BrowserAuthentication;
            connection.HttpBrowser = (int) favorite.HttpBrowser;
            connection.Url = favorite.Url;
            connection.PuttyConnectionType = (int)favorite.PuttyConnectionType;
            connection.PuttySession = favorite.PuttySession;
            connection.PuttyCompression = favorite.PuttyCompression;
            connection.PuttyPasswordTimeout = favorite.PuttyPasswordTimeout;
            connection.PuttyVerbose = favorite.PuttyVerbose;
            connection.PuttyShowOptions = favorite.PuttyShowOptions;
            connection.PuttyCloseWindowOnExit = (int)favorite.PuttyCloseWindowOnExit;

            connection.GenericWorkingDirectory = favorite.GenericWorkingDirectory;
            connection.GenericProgramPath = favorite.GenericProgramPath;
            connection.GenericArguments = favorite.GenericArguments;
            connection.RAdminPhonebookPath = favorite.RAdminPhonebookPath;
            connection.RAdminThrough = favorite.RAdminThrough;
            connection.RAdminThroughServerName = favorite.RAdminThroughServerName;
            connection.RAdminThroughPort = favorite.RAdminThroughPort;
            connection.RAdminStandardConnectionMode = favorite.RAdminStandardConnectionMode;
            connection.RAdminTelnetMode = favorite.RAdminTelnetMode;
            connection.RAdminViewOnlyMode = favorite.RAdminViewOnlyMode;
            connection.RAdminFileTransferMode = favorite.RAdminFileTransferMode;
            connection.RAdminShutdown = favorite.RAdminShutdown;
            connection.RAdminChatMode = favorite.RAdminChatMode;
            connection.RAdminVoiceChatMode = favorite.RAdminVoiceChatMode;
            connection.RAdminSendTextMessageMode = favorite.RAdminSendTextMessageMode;
            connection.RAdminUseFullScreen = favorite.RAdminUseFullScreen;
            connection.RAdminUpdates = favorite.RAdminUpdates;
            connection.RAdminColorMode = favorite.RAdminColorMode;
            connection.ConsoleRows = favorite.ConsoleRows;
            connection.ConsoleCols = favorite.ConsoleCols;
            connection.ConsoleFont = favorite.ConsoleFont;
            connection.ConsoleBackColor = favorite.ConsoleBackColor;
            connection.ConsoleTextColor = favorite.ConsoleTextColor;
            connection.ConsoleCursorColor = favorite.ConsoleCursorColor;
            connection.Ssh1 = favorite.Ssh1;
            connection.AuthMethod = (int)favorite.AuthMethod;
            connection.KeyTag = favorite.KeyTag;
            connection.VncAutoScale = favorite.VncAutoScale;
            connection.VncViewOnly = favorite.VncViewOnly;
            connection.VncDisplayNumber = favorite.VncDisplayNumber;
            connection.VmrcReducedColorsMode = favorite.VmrcReducedColorsMode;
            connection.VmrcAdministratorMode = favorite.VmrcAdministratorMode;
            connection.IcaApplicationName = favorite.IcaApplicationName;
            connection.IcaServerIni = favorite.IcaServerIni;
            connection.IcaClientIni = favorite.IcaClientIni;
            connection.IcaEnableEncryption = favorite.IcaEnableEncryption;
            connection.IcaEncryptionLevel = favorite.IcaEncryptionLevel;
            connection.LoadBalanceInfo = favorite.LoadBalanceInfo;
            connection.ConnectToConsole = favorite.ConnectToConsole;
            connection.RedirectPrinters = favorite.RedirectPrinters;
            connection.RedirectSmartCards = favorite.RedirectSmartCards;
            connection.RedirectClipboard = favorite.RedirectClipboard;
            connection.RedirectDevices = favorite.RedirectDevices;
            connection.TsgwUsageMethod = favorite.TsgwUsageMethod;
            connection.TsgwHostname = favorite.TsgwHostname;
            connection.TsgwCredsSource = favorite.TsgwCredsSource;
            connection.TsgwSeparateLogin = favorite.TsgwSeparateLogin;
            connection.TsgwUsername = favorite.TsgwUsername;
            connection.TsgwDomain = favorite.TsgwDomain;
            connection.TsgwEncryptedPassword = favorite.TsgwEncryptedPassword;
            connection.Sounds = (int)favorite.Sounds;
            connection.RedirectedDrives = favorite.redirectedDrives;
            connection.RedirectPorts = favorite.RedirectPorts;
            connection.ShutdownTimeout = favorite.ShutdownTimeout;
            connection.OverallTimeout = favorite.OverallTimeout;
            connection.ConnectionTimeout = favorite.ConnectionTimeout;
            connection.IdleTimeout = favorite.IdleTimeout;
            connection.SecurityWorkingFolder = favorite.SecurityWorkingFolder;
            connection.SecurityStartProgram = favorite.SecurityStartProgram;
            connection.SecurityFullScreen = favorite.SecurityFullScreen;
            connection.EnableSecuritySettings = favorite.EnableSecuritySettings;
            connection.GrabFocusOnConnect = favorite.GrabFocusOnConnect;
            connection.EnableEncryption = favorite.EnableEncryption;
            connection.DisableWindowsKey = favorite.DisableWindowsKey;
            connection.DoubleClickDetect = favorite.DoubleClickDetect;
            connection.DisplayConnectionBar = favorite.DisplayConnectionBar;
            connection.DisableControlAltDelete = favorite.DisableControlAltDelete;
            connection.AcceleratorPassthrough = favorite.AcceleratorPassthrough;
            connection.EnableCompression = favorite.EnableCompression;
            connection.BitmapPeristence = favorite.BitmapPeristence;
            connection.EnableTlsAuthentication = favorite.EnableTlsAuthentication;
            connection.EnableNlaAuthentication = favorite.EnableNlaAuthentication;
            connection.AllowBackgroundInput = favorite.AllowBackgroundInput;
            connection.DisableTheming = favorite.DisableTheming;
            connection.DisableMenuAnimations = favorite.DisableMenuAnimations;
            connection.DisableFullWindowDrag = favorite.DisableFullWindowDrag;
            connection.DisableCursorBlinking = favorite.DisableCursorBlinking;
            connection.EnableDesktopComposition = favorite.EnableDesktopComposition;
            connection.EnableFontSmoothing = favorite.EnableFontSmoothing;
            connection.DisableCursorShadow = favorite.DisableCursorShadow;
            connection.DisableWallPaper = favorite.DisableWallPaper;
            connection.Colors = (int)favorite.Colors;
            connection.DesktopShare = favorite.DesktopShare;

            return connection;
        }