/// <summary>
        /// Ends a connection to the server. It is called after processing is completed with the server to release resources
        /// </summary>
        void IMAExtensible2Password.ClosePasswordConnection()
        {
            OperationBase operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is PasswordEndOperation);

            if (operation != null)
            {
                try
                {
                    SshConnection.ExecuteOperation(operation);
                }
                catch (Exception ex)
                {
                    Logger.WriteLine("Could not perform password end operation");
                    Logger.WriteException(ex);
                    throw new ExtensibleExtensionException("Password end operation failed", ex);
                }
            }

            try
            {
                SshConnection.CloseSshConnection();
            }
            catch (Exception ex)
            {
                Logger.WriteLine("Could not close SSH connection");
                Logger.WriteException(ex);
            }

            Logger.WriteLine("Ending password operation");
            Logger.WriteSeparatorLine('*');
        }
        /// <summary>
        /// Ends an export session
        /// </summary>
        /// <param name="exportRunStep">The results of the export session close</param>
        void IMAExtensible2CallExport.CloseExportConnection(CloseExportConnectionRunStep exportRunStep)
        {
            OperationBase operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ExportEndOperation);

            if (operation != null)
            {
                try
                {
                    SshConnection.ExecuteOperation(operation);
                }
                catch (Exception ex)
                {
                    Logger.WriteLine("Could not perform export end operation");
                    Logger.WriteException(ex);
                    throw new ExtensibleExtensionException("Export end operation failed", ex);
                }
            }

            try
            {
                SshConnection.CloseSshConnection();
            }
            catch (Exception ex)
            {
                Logger.WriteLine("Could not close SSH connection");
                Logger.WriteException(ex);
            }

            Logger.WriteLine("Export Complete");
            Logger.WriteSeparatorLine('*');
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the objects required for import
        /// </summary>
        /// <param name="schemaTypes">The object classes to import</param>
        /// <param name="operationType">The type of import operation</param>
        /// <returns>A list of CSEntryChange objects</returns>
        public static IEnumerable <CSEntryChange> GetObjects(KeyedCollection <string, SchemaType> schemaTypes, OperationType operationType)
        {
            List <CSEntryChange> csentries = new List <CSEntryChange>();

            foreach (ObjectOperationGroup group in MAConfig.OperationGroups.Where(t => schemaTypes.Contains(t.ObjectClass)))
            {
                OperationBase operation;
                if (operationType == OperationType.Delta)
                {
                    operation = group.ObjectOperations.FirstOrDefault(t => t is ImportDeltaOperation);
                }
                else
                {
                    operation = group.ObjectOperations.FirstOrDefault(t => t is ImportFullOperation);
                }

                if (operation == null)
                {
                    throw new ExtensibleExtensionException("No import operation was defined for the object type " + group.ObjectClass);
                }

                OperationResult result = SshConnection.ExecuteOperation(operation);
                csentries.AddRange(GetCSEntryChanges(result, schemaTypes[group.ObjectClass]));
            }

            return(csentries);
        }
        /// <summary>
        /// Configures the import session at the beginning of an import
        /// </summary>
        /// <param name="configParameters">The configuration parameters supplied to this management agent</param>
        /// <param name="types">The schema types that apply to this import run</param>
        /// <param name="importRunStep">The definition of the current run step</param>
        /// <returns>Results of the import setup</returns>
        OpenImportConnectionResults IMAExtensible2CallImport.OpenImportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenImportConnectionRunStep importRunStep)
        {
            try
            {
                ManagementAgent.MAParameters = new MAParameters(configParameters);
                Logger.LogPath = ManagementAgent.MAParameters.LogPath;
                Logger.WriteSeparatorLine('*');
                Logger.WriteLine("Starting Import");

                MAConfig.Load(ManagementAgent.MAParameters.MAConfigurationFilePath);

                SshConnection.OpenSshConnection(ManagementAgent.MAParameters);
                OperationBase operation;
                this.ImportType     = importRunStep.ImportType;
                this.schemaTypes    = types.Types;
                this.importPageSize = importRunStep.PageSize;

                if (importRunStep.ImportType == OperationType.Delta)
                {
                    operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ImportDeltaStartOperation);
                }
                else
                {
                    operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ImportFullStartOperation);
                }

                if (operation != null)
                {
                    try
                    {
                        SshConnection.ExecuteOperation(operation);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform import start operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Import start operation failed", ex);
                    }
                }

                this.importEnumerator = CSEntryImport.GetObjects(this.schemaTypes, importRunStep.ImportType).GetEnumerator();
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the open import connection operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the open import connection operation", ex);
            }

            OpenImportConnectionResults results = new OpenImportConnectionResults();

            return(new OpenImportConnectionResults());
        }
        /// <summary>
        /// Closes the import session
        /// </summary>
        /// <param name="importRunStepInfo">The current run step</param>
        /// <returns>Results of the import session close</returns>
        CloseImportConnectionResults IMAExtensible2CallImport.CloseImportConnection(CloseImportConnectionRunStep importRunStepInfo)
        {
            try
            {
                OperationBase operation;
                if (this.ImportType == OperationType.Delta)
                {
                    operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ImportDeltaEndOperation);
                }
                else
                {
                    operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ImportFullEndOperation);
                }

                if (operation != null)
                {
                    try
                    {
                        SshConnection.ExecuteOperation(operation);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform import end operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Import end operation failed", ex);
                    }
                }

                try
                {
                    SshConnection.CloseSshConnection();
                }
                catch (Exception ex)
                {
                    Logger.WriteLine("Could not close SSH connection");
                    Logger.WriteException(ex);
                }

                Logger.WriteLine("Import Complete");
                Logger.WriteSeparatorLine('*');
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the open export connection operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the open export connection operation", ex);
            }

            return(new CloseImportConnectionResults());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Deletes an object from the target system
        /// </summary>
        /// <param name="csentry">The CSEntryChange containing the new object and its attributes</param>
        private static void PerformCSEntryExportDelete(CSEntryChange csentry)
        {
            ObjectOperationGroup group = MAConfig.OperationGroups[csentry.ObjectType];

            if (group == null)
            {
                throw new InvalidOperationException("The object class does not have a delete operation");
            }

            OperationBase   operation = group.ObjectOperations.FirstOrDefault(t => t is ExportDeleteOperation);
            OperationResult result    = SshConnection.ExecuteOperation(operation, csentry);

            if (result != null)
            {
                Logger.WriteLine("ExportDelete on object '{0}' returned: {1}", csentry.DN, result.ExecutedCommands.Last().Result);
            }
        }
        /// <summary>
        /// Begins a password connection to the server
        /// </summary>
        /// <param name="configParameters">The collection of configuration parameters</param>
        /// <param name="partition">The partition details on which the password operation should occur</param>
        void IMAExtensible2Password.OpenPasswordConnection(KeyedCollection <string, ConfigParameter> configParameters, Partition partition)
        {
            try
            {
                ManagementAgent.MAParameters = new MAParameters(configParameters);
                Logger.LogPath = ManagementAgent.MAParameters.LogPath;
                Logger.WriteSeparatorLine('*');
                Logger.WriteLine("Starting password operation");

                MAConfig.Load(ManagementAgent.MAParameters.MAConfigurationFilePath);

                SshConnection.OpenSshConnection(ManagementAgent.MAParameters);

                OperationBase operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is PasswordStartOperation);

                if (operation != null)
                {
                    try
                    {
                        SshConnection.ExecuteOperation(operation);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform password start operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Password start operation failed", ex);
                    }
                }
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the open password connection operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the open password connection operation", ex);
            }
        }
        /// <summary>
        /// Begins an export session
        /// </summary>
        /// <param name="configParameters">The configuration parameters supplied to this management agent</param>
        /// <param name="types">The schema types that apply to this export run</param>
        /// <param name="exportRunStep">The definition of the current run step</param>
        void IMAExtensible2CallExport.OpenExportConnection(KeyedCollection <string, ConfigParameter> configParameters, Schema types, OpenExportConnectionRunStep exportRunStep)
        {
            try
            {
                ManagementAgent.MAParameters = new MAParameters(configParameters);
                Logger.LogPath = ManagementAgent.MAParameters.LogPath;
                Logger.WriteSeparatorLine('*');
                Logger.WriteLine("Starting Export");

                MAConfig.Load(ManagementAgent.MAParameters.MAConfigurationFilePath);

                SshConnection.OpenSshConnection(ManagementAgent.MAParameters);

                OperationBase operation = MAConfig.GlobalOperations.FirstOrDefault(t => t is ExportStartOperation);

                if (operation != null)
                {
                    try
                    {
                        SshConnection.ExecuteOperation(operation);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform export start operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Export start operation failed", ex);
                    }
                }
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the open export connection operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the open export connection operation", ex);
            }
        }
        /// <summary>
        /// Sets the password for the connector space object
        /// </summary>
        /// <param name="csentry">The CSEntry object for the user</param>
        /// <param name="newPassword">The new password</param>
        /// <param name="options">A PasswordOptions object specifying the options for setting the password</param>
        void IMAExtensible2Password.SetPassword(CSEntry csentry, System.Security.SecureString newPassword, PasswordOptions options)
        {
            try
            {
                Logger.LogLevel = LogLevel.Debug;
                PasswordSetOperation operation = MAConfig.OperationGroups[csentry.ObjectType].ObjectOperations.FirstOrDefault(t => t is PasswordSetOperation) as PasswordSetOperation;

                if (operation != null)
                {
                    try
                    {
                        Logger.WriteLine("Attempting to set password for {0}", csentry.DN.ToString());
                        SshConnection.ExecuteOperation(operation, csentry, newPassword.ToUnsecureString());
                        Logger.WriteLine("Set password for {0} successfully", csentry.DN.ToString());
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform set password operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Set password set operation failed", ex);
                    }
                }
                else
                {
                    Logger.WriteLine("Could not set password for {0} as no password set operation was defined for this object type", csentry.DN.ToString());
                }
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the password set operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the password set operation", ex);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Changes the password for the connector space object
        /// </summary>
        /// <param name="csentry">The CSEntry object for the user</param>
        /// <param name="oldPassword">The old password</param>
        /// <param name="newPassword">The new password</param>
        void IMAExtensible2Password.ChangePassword(CSEntry csentry, System.Security.SecureString oldPassword, System.Security.SecureString newPassword)
        {
            try
            {
                PasswordChangeOperation operation = MAConfig.OperationGroups[csentry.ObjectType.ToString()].ObjectOperations.FirstOrDefault(t => t is PasswordChangeOperation) as PasswordChangeOperation;

                if (operation != null)
                {
                    try
                    {
                        Logger.WriteLine("Attempting to change password for {0}", csentry.DN.ToString());
                        SshConnection.ExecuteOperation(operation, csentry, oldPassword.ToUnsecureString(), newPassword.ToUnsecureString());
                        Logger.WriteLine("Changed password for {0} successfully", csentry.DN.ToString());
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine("Could not perform password change operation");
                        Logger.WriteException(ex);
                        throw new ExtensibleExtensionException("Set password change operation failed", ex);
                    }
                }
                else
                {
                    Logger.WriteLine("Could not change password for {0} as no password change operation was defined for this object type", csentry.DN.ToString());
                }
            }
            catch (ExtensibleExtensionException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Logger.WriteLine("A exception occured during the password change operartion");
                Logger.WriteException(ex);
                throw new ExtensibleExtensionException("An exception occured during the password change operation", ex);
            }
        }