/// <summary>
        /// Executes a synchronous command
        /// </summary>
        /// <param name="result">The result object for the current operation</param>
        /// <param name="command">The definition of the command to execute</param>
        /// <param name="sshCommand">The SSH command object to execute</param>
        private static void ExecuteSyncCommand(OperationResult result, SyncCommand command, SshCommand sshCommand)
        {
            sshCommand.Execute();
            Logger.WriteLine("Command returned exit code {0}", sshCommand.ExitStatus.ToString());
            Logger.WriteRaw(sshCommand.Result, LogLevel.Debug);

            if (!command.SuccessCodes.Contains(sshCommand.ExitStatus))
            {
                if (!string.IsNullOrWhiteSpace(sshCommand.Error))
                {
                    throw new Microsoft.MetadirectoryServices.ExtensibleExtensionException(sshCommand.Error);
                }
                else
                {
                    throw new Microsoft.MetadirectoryServices.ExtensibleExtensionException("The command returned an exit code that was not in the list of successful exit codes: " + sshCommand.ExitStatus.ToString());
                }
            }

            if (command.HasObjects)
            {
                result.ExecutedCommandsWithObjects.Add(sshCommand);
            }

            result.ExecutedCommands.Add(sshCommand);
        }
        /// <summary>
        /// Executes a synchronous command that iterates through the values of a multi-valued attribute
        /// </summary>
        /// <param name="csentry">The CSEntryChange to apply to this command</param>
        /// <param name="result">The result object for the current operation</param>
        /// <param name="command">The definition of the command to execute</param>
        private static void ExecuteForEachSyncCommand(CSEntryChange csentry, OperationResult result, SyncCommand command)
        {
            if (!csentry.AttributeChanges.Contains(command.ForEachAttribute.Name))
            {
                throw new ArgumentException("The for-each command could not be executed because the attribute was not present in the CSEntryChange");
            }

            foreach (string commandText in command.Command.ExpandDeclarationWithMultiValued(csentry, command.ForEachAttribute, command.ForEachValueModificationType))
            {
                SshCommand sshCommand = client.CreateCommand(commandText);
                Logger.WriteLine("Executing for-each command: " + commandText);
                ExecuteSyncCommand(result, command, sshCommand);
            }
        }
        /// <summary>
        /// Executes a synchronous command against a CSEntry object (typically a password change)
        /// </summary>
        /// <param name="csentry">The CSEntry to execute the command against</param>
        /// <param name="result">The result object for the current operation</param>
        /// <param name="command">The definition of the command to execute</param>
        /// <param name="oldPassword">The old password, or null if performing a password set as opposed to a password change</param>
        /// <param name="newPassword">The new password</param>
        private static void ExecuteSyncCommand(CSEntry csentry, OperationResult result, SyncCommand command, string oldPassword, string newPassword)
        {
            SshCommand sshCommand = client.CreateCommand(command.Command.ExpandDeclaration(csentry, oldPassword, newPassword, false));

            Logger.WriteLine("Executing command: " + command.Command.ExpandDeclaration(csentry, oldPassword, newPassword, true));
            ExecuteSyncCommand(result, command, sshCommand);
        }
 /// <summary>
 /// Executes a synchronous command
 /// </summary>
 /// <param name="csentry">The CSEntryChange to apply to this command</param>
 /// <param name="result">The result object for the current operation</param>
 /// <param name="command">The definition of the command to execute</param>
 private static void ExecuteSyncCommand(CSEntryChange csentry, OperationResult result, SyncCommand command)
 {
     if (command.ForEachAttribute == null)
     {
         string     commandText = command.Command.ExpandDeclaration(csentry, false, false);
         string     logText     = command.Command.ExpandDeclaration(csentry, false, true);
         SshCommand sshCommand  = client.CreateCommand(commandText);
         Logger.WriteLine("Executing command: " + logText);
         ExecuteSyncCommand(result, command, sshCommand);
     }
     else
     {
         ExecuteForEachSyncCommand(csentry, result, command);
     }
 }