Esempio n. 1
0
        internal CSEntryChange GetObject()
        {
            CSEntryChangeDetached csentry = new CSEntryChangeDetached(
                this.Identifier,
                this.ObjectModificationType,
                this.ErrorCodeImport,
                this.AttributeChanges?.Select(t => t.Name).ToList() ?? new List <string>());

            csentry.DN          = this.DN;
            csentry.ErrorDetail = this.ErrorDetail;
            csentry.ErrorName   = this.ErrorName;
            csentry.ObjectType  = this.ObjectType;

            if (this.AnchorAttributes != null)
            {
                foreach (AnchorAttribute attribute in this.AnchorAttributes)
                {
                    csentry.AnchorAttributes.Add(attribute);
                }
            }

            if (this.AttributeChanges != null)
            {
                foreach (AttributeChange attribute in this.AttributeChanges)
                {
                    csentry.AttributeChanges.Add(attribute);
                }
            }

            return(csentry);
        }
Esempio n. 2
0
        public void CreateResource(AcmaResource resource)
        {
            try
            {
                Monitor.Enter(ServiceMain.Lock);

                if (resource.ObjectID == Guid.Empty)
                {
                    resource.ObjectID = new Guid();
                }

                CSEntryChange csentry = CSEntryChangeDetached.Create();
                csentry.ObjectModificationType = ObjectModificationType.Add;
                csentry.DN         = resource.ObjectID.ToString();
                csentry.ObjectType = resource.ObjectType;

                foreach (var item in resource.Attributes)
                {
                    csentry.AttributeChanges.Add(this.AvpToAttributeChange(item, AttributeModificationType.Add));
                }

                bool refRetry;
                CSEntryExport.PutExportEntry(csentry, out refRetry);
            }
            finally
            {
                Monitor.Exit(ServiceMain.Lock);
            }
        }
Esempio n. 3
0
        public void DeleteResource(string id)
        {
            try
            {
                Monitor.Enter(ServiceMain.Lock);
                CSEntryChange csentry = CSEntryChangeDetached.Create();
                csentry.ObjectModificationType = ObjectModificationType.Delete;
                csentry.DN = id;

                bool refRetry;
                CSEntryExport.PutExportEntry(csentry, out refRetry);
            }
            finally
            {
                Monitor.Exit(ServiceMain.Lock);
            }
        }
        public static CSEntryChangeResult PutCSEntryChangeObject(CSEntryChange csentry, SchemaType type, IManagementAgentParameters config)
        {
            MASchemaType maType = ManagementAgent.Schema[type.Name];

            CSEntryChangeDetached deltaCSEntry = new CSEntryChangeDetached(Guid.NewGuid(), ObjectModificationType.Unconfigured, MAImportError.Success, null);

            foreach (var anchorAttributeName in maType.AnchorAttributeNames)
            {
                AnchorAttribute anchor = csentry.GetAnchorAttribute(anchorAttributeName);

                if (anchor != null)
                {
                    deltaCSEntry.AnchorAttributes.Add(anchor);
                }
            }

            deltaCSEntry.ObjectType = csentry.ObjectType;

            try
            {
                switch (csentry.ObjectModificationType)
                {
                case ObjectModificationType.Add:
                    return(ExportProcessor.PutCSEntryChangeAdd(csentry, deltaCSEntry, maType, type, config));

                case ObjectModificationType.Delete:
                    return(ExportProcessor.PutCSEntryChangeDelete(csentry, deltaCSEntry, maType));

                case ObjectModificationType.Update:
                    return(ExportProcessor.PutCSEntryChangeUpdate(csentry, deltaCSEntry, maType, type, config));

                default:
                case ObjectModificationType.None:
                case ObjectModificationType.Replace:
                case ObjectModificationType.Unconfigured:
                    throw new InvalidOperationException($"Unknown or unsupported modification type: {csentry.ObjectModificationType} on object {csentry.DN}");
                }
            }
            finally
            {
                CSEntryChangeQueue.Add(deltaCSEntry);
            }
        }
Esempio n. 5
0
        public void ReplaceResource(string id, AcmaResource resource)
        {
            try
            {
                Monitor.Enter(ServiceMain.Lock);
                CSEntryChange csentry = CSEntryChangeDetached.Create();
                csentry.ObjectModificationType = ObjectModificationType.Replace;
                csentry.DN = id;

                foreach (var item in resource.Attributes)
                {
                    csentry.AttributeChanges.Add(this.AvpToAttributeChange(item, AttributeModificationType.Add));
                }

                bool refRetry;
                CSEntryExport.PutExportEntry(csentry, out refRetry);
            }
            finally
            {
                Monitor.Exit(ServiceMain.Lock);
            }
        }