/// <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> /// Validates the configuration file parameters, and ensures the configuration file is valid and can be opened /// </summary> /// <param name="configParameters">The configuration parameters from the user interface</param> /// <param name="page">The configuration page</param> /// <returns>A ParameterValidationResult containing the validation status</returns> public static ParameterValidationResult ValidateConfigFile(KeyedCollection <string, ConfigParameter> configParameters, ConfigParameterPage page) { ParameterValidationResult myResults = new ParameterValidationResult(); string path = string.Empty; if (!configParameters.Contains(MAParameterNames.MAConfigurationFile)) { myResults.Code = ParameterValidationResultCode.Failure; myResults.ErrorMessage = "A configuration file must be specified"; myResults.ErrorParameter = MAParameterNames.MAConfigurationFile; return(myResults); } else { path = configParameters[MAParameterNames.MAConfigurationFile].Value; if (!System.IO.Path.IsPathRooted(path)) { path = System.IO.Path.Combine(Utils.ExtensionsDirectory, path); } } if (!System.IO.File.Exists(path)) { myResults.Code = ParameterValidationResultCode.Failure; myResults.ErrorMessage = "The configuration file does not exist"; myResults.ErrorParameter = MAParameterNames.MAConfigurationFile; return(myResults); } else { try { MAConfig.Load(path); } catch (Exception ex) { myResults.Code = ParameterValidationResultCode.Failure; myResults.ErrorMessage = string.Format("The configuration file could not be loaded\n{0}\n{1}", ex.Message, ex.InnerException == null ? string.Empty : ex.InnerException.Message); myResults.ErrorParameter = MAParameterNames.MAConfigurationFile; return(myResults); } } myResults.Code = ParameterValidationResultCode.Success; return(myResults); }
/// <summary> /// Gets the schema that applies to the objects in this management agent /// </summary> /// <param name="configParameters">The configuration parameters supplied to this management agent</param> /// <returns>The Schema defining objects and attributes applicable to this management agent</returns> Schema IMAExtensible2GetSchema.GetSchema(KeyedCollection <string, ConfigParameter> configParameters) { try { ManagementAgent.MAParameters = new MAParameters(configParameters); Logger.LogPath = ManagementAgent.MAParameters.LogPath; Logger.WriteSeparatorLine('*'); Logger.WriteLine("Loading Schema"); MAConfig.Load(ManagementAgent.MAParameters.MAConfigurationFilePath); Schema schema = Schema.Create(); foreach (MASchemaObject schemaObject in MASchema.Objects) { SchemaType schemaType = SchemaType.Create(schemaObject.ObjectClass, true); schemaType.Attributes.Add(SchemaAttribute.CreateAnchorAttribute("entry-dn", AttributeType.String, AttributeOperation.ImportOnly)); foreach (MASchemaAttribute attribute in schemaObject.Attributes) { if (attribute.IsMultiValued) { schemaType.Attributes.Add(SchemaAttribute.CreateMultiValuedAttribute(attribute.Name, attribute.Type, attribute.Operation)); } else { schemaType.Attributes.Add(SchemaAttribute.CreateSingleValuedAttribute(attribute.Name, attribute.Type, attribute.Operation)); } } schema.Types.Add(schemaType); } Logger.WriteLine("Schema loaded successfully"); return(schema); } catch (Exception ex) { Logger.WriteException(ex); throw new ExtensibleExtensionException("The schema could not be loaded: " + ex.Message, ex); } }
/// <summary> /// Gets the capabilities of this management agent /// </summary> /// <param name="configParameters">The current configuration parameters for this MA</param> /// <returns>The capabilities of this management agent</returns> MACapabilities IMAExtensible2GetCapabilitiesEx.GetCapabilitiesEx(KeyedCollection <string, ConfigParameter> configParameters) { ManagementAgent.MAParameters = new MAParameters(configParameters); MAConfig.Load(ManagementAgent.MAParameters.MAConfigurationFilePath); MACapabilities capabilities = new MACapabilities { ConcurrentOperation = true, ObjectRename = MAConfig.Capabilities.ObjectRenameAllowed, DeleteAddAsReplace = MAConfig.Capabilities.DeleteAddAsReplace, ExportType = MAConfig.Capabilities.ObjectUpdateMode, DeltaImport = MAConfig.Capabilities.DeltaImport, DistinguishedNameStyle = MADistinguishedNameStyle.Generic, NoReferenceValuesInFirstExport = false, Normalizations = MANormalizations.None, IsDNAsAnchor = false }; return(capabilities); }
/// <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); } }