Example #1
0
        public void ExpandSimpleAttributeSVBoolean()
        {
            AcmaSchemaAttribute   attribute    = ActiveConfig.DB.GetAttribute("connectedToCallista");
            AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person");
            string declarationString           = "{connectedToCallista}";
            AttributeDeclarationParser p       = new AttributeDeclarationParser(declarationString);
            AttributeDeclaration       target  = p.GetAttributeDeclaration();

            CSEntryChange sourceObject = CSEntryChange.Create();

            sourceObject.ObjectModificationType = ObjectModificationType.Add;
            sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, true));

            object value = target.Expand(sourceObject).First();

            if (value == null)
            {
                Assert.Fail("The declaration string did not return a value");
            }
            else if (!(value is bool))
            {
                Assert.Fail("The declaration string returned the wrong data type");
            }
            else if ((bool)value != true)
            {
                Assert.Fail("The declaration string did not return the expected value");
            }
        }
Example #2
0
        public void ExpandSimpleAttributeMVLongWithTransforms()
        {
            AcmaSchemaAttribute   attribute    = ActiveConfig.DB.GetAttribute("expiryDates");
            AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person");
            string declarationString           = "{expiryDates>>Add30Days}";
            AttributeDeclarationParser p       = new AttributeDeclarationParser(declarationString);
            AttributeDeclaration       target  = p.GetAttributeDeclaration();

            CSEntryChange sourceObject = CSEntryChange.Create();

            sourceObject.ObjectModificationType = ObjectModificationType.Add;
            sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, new List <object>()
            {
                1L, 2L, 3L, 4L
            }));

            object value = target.Expand(sourceObject);

            if (value == null)
            {
                Assert.Fail("The declaration string did not return a value");
            }
            else if (!(value is IList <object>))
            {
                Assert.Fail("The declaration string returned the wrong data type");
            }
            else if (!((IList <object>)value).SequenceEqual(new List <object>()
            {
                25920000000001L, 25920000000002L, 25920000000003L, 25920000000004L
            }))
            {
                Assert.Fail("The declaration string did not return the expected value");
            }
        }
Example #3
0
        public void ExpandSimpleAttributeMVStringWithTransforms()
        {
            AcmaSchemaAttribute   attribute    = ActiveConfig.DB.GetAttribute("mailAlternateAddresses");
            AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person");
            string declarationString           = "{mailAlternateAddresses>>ToUpperCase}";
            AttributeDeclarationParser p       = new AttributeDeclarationParser(declarationString);
            AttributeDeclaration       target  = p.GetAttributeDeclaration();

            CSEntryChange sourceObject = CSEntryChange.Create();

            sourceObject.ObjectModificationType = ObjectModificationType.Add;
            sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, new List <object>()
            {
                "*****@*****.**", "*****@*****.**", "*****@*****.**"
            }));

            object value = target.Expand(sourceObject);

            if (value == null)
            {
                Assert.Fail("The declaration string did not return a value");
            }
            else if (!(value is IList <object>))
            {
                Assert.Fail("The declaration string returned the wrong data type");
            }
            else if (!((IList <object>)value).SequenceEqual(new List <object>()
            {
                "*****@*****.**", "*****@*****.**", "*****@*****.**"
            }))
            {
                Assert.Fail("The declaration string did not return the expected value");
            }
        }
        /// <summary>
        /// Converts a CSEntryChange from an 'replace' modification type to 'update', converting the contained AttributeChanges from 'add' to 'replace', and adding in the appropriate 'delete' AttributeChanges
        /// </summary>
        /// <param name="csentry">The CSEntryChange to modify</param>
        /// <returns>A copy of the original CSEntryChange with the modification type set to 'update'</returns>
        public static CSEntryChange ConvertCSEntryChangeReplaceToUpdate(this CSEntryChange csentry, MAObjectHologram maObject)
        {
            CSEntryChange newcsentry = CSEntryChange.Create();

            newcsentry.ObjectModificationType = ObjectModificationType.Update;
            newcsentry.ObjectType             = csentry.ObjectType;
            newcsentry.DN = csentry.DN;
            AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass(csentry.ObjectType);

            foreach (AttributeChange attributeChange in csentry.AttributeChanges)
            {
                AttributeChange newAttributeChange = AttributeChange.CreateAttributeReplace(attributeChange.Name, attributeChange.ValueChanges.Select(t => t.Value).ToList <object>());
                newcsentry.AttributeChanges.Add(newAttributeChange);
            }

            foreach (AcmaSchemaAttribute attribute in objectClass.Attributes.Where(t => !t.IsBuiltIn && !t.IsInheritedInClass(objectClass.Name)))
            {
                if (!csentry.AttributeChanges.Any(t => t.Name == attribute.Name))
                {
                    if (maObject.HasAttribute(attribute))
                    {
                        newcsentry.AttributeChanges.Add(AttributeChange.CreateAttributeDelete(attribute.Name));
                    }
                }
            }

            Logger.WriteLine("Converted CSEntryChangeReplace to CSEntryChangeUpdate", LogLevel.Debug);
            return(newcsentry);
        }
Example #5
0
        public void ExpandSimpleAttributeMVReference()
        {
            AcmaSchemaAttribute   attribute    = ActiveConfig.DB.GetAttribute("directReports");
            AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person");
            string declarationString           = "{directReports}";
            AttributeDeclarationParser p       = new AttributeDeclarationParser(declarationString);
            AttributeDeclaration       target  = p.GetAttributeDeclaration();

            CSEntryChange sourceObject = CSEntryChange.Create();

            sourceObject.ObjectModificationType = ObjectModificationType.Add;
            sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, new List <object>()
            {
                new Guid("fb116a90-35e3-47e9-92b7-679c4821e648"), new Guid("352285df-3fdc-468e-9412-70d62a62cefe"), new Guid("50ac8dbb-15fe-485c-8f02-87a77ab68a7b")
            }));

            object value = target.Expand(sourceObject);

            if (value == null)
            {
                Assert.Fail("The declaration string did not return a value");
            }
            else if (!(value is IList <object>))
            {
                Assert.Fail("The declaration string returned the wrong data type");
            }
            else if (!((IList <object>)value).SequenceEqual(new List <object>()
            {
                new Guid("fb116a90-35e3-47e9-92b7-679c4821e648"), new Guid("352285df-3fdc-468e-9412-70d62a62cefe"), new Guid("50ac8dbb-15fe-485c-8f02-87a77ab68a7b")
            }))
            {
                Assert.Fail("The declaration string did not return the expected value");
            }
        }
Example #6
0
        public void ExpandSimpleAttributeSVLongWithTransforms()
        {
            AcmaSchemaAttribute   attribute    = ActiveConfig.DB.GetAttribute("sapExpiryDate");
            AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person");
            string declarationString           = "{sapExpiryDate>>Add30Days}";
            AttributeDeclarationParser p       = new AttributeDeclarationParser(declarationString);
            AttributeDeclaration       target  = p.GetAttributeDeclaration();

            CSEntryChange sourceObject = CSEntryChange.Create();

            sourceObject.ObjectModificationType = ObjectModificationType.Add;
            sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, 1L));

            object value = target.Expand(sourceObject).First();

            if (value == null)
            {
                Assert.Fail("The declaration string did not return a value");
            }
            else if (!(value is long))
            {
                Assert.Fail("The declaration string returned the wrong data type");
            }
            else if ((long)value != 25920000000001L)
            {
                Assert.Fail("The declaration string did not return the expected value");
            }
        }
Example #7
0
        public void ExpandSimpleAttributeSVStringWithTransforms()
        {
            AcmaSchemaAttribute   attribute    = ActiveConfig.DB.GetAttribute("mail");
            AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person");
            string declarationString           = "{mail>>ToUpperCase}";
            AttributeDeclarationParser p       = new AttributeDeclarationParser(declarationString);
            AttributeDeclaration       target  = p.GetAttributeDeclaration();

            CSEntryChange sourceObject = CSEntryChange.Create();

            sourceObject.ObjectModificationType = ObjectModificationType.Add;
            sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, "*****@*****.**"));

            object value = target.Expand(sourceObject).First();

            if (value == null)
            {
                Assert.Fail("The declaration string did not return a value");
            }
            else if (!(value is string))
            {
                Assert.Fail("The declaration string returned the wrong data type");
            }
            else if ((string)value != "*****@*****.**")
            {
                Assert.Fail("The declaration string did not return the expected value");
            }
        }
        protected override void ProcessRecord()
        {
            Global.ThrowIfNotConnected(this);

            try
            {
                AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass(this.ObjectClass);
                AcmaSchemaAttribute   attribute   = ActiveConfig.DB.GetAttribute(this.Attribute);

                if (this.InheritanceSourceAttribute == null)
                {
                    ActiveConfig.DB.CreateMapping(objectClass, attribute, objectClass.MappingsBindingList);
                }
                else
                {
                    AcmaSchemaAttribute   inheritedAttribute           = ActiveConfig.DB.GetAttribute(this.InheritanceSourceAttribute);
                    AcmaSchemaObjectClass inheritanceSourceObjectClass = ActiveConfig.DB.GetObjectClass(this.InheritanceSourceClass);
                    AcmaSchemaAttribute   innheritanceReference        = ActiveConfig.DB.GetAttribute(this.InheritanceSourceReference);

                    ActiveConfig.DB.CreateMapping(objectClass, attribute, innheritanceReference, inheritanceSourceObjectClass, inheritedAttribute, objectClass.MappingsBindingList);
                }

                ActiveConfig.DB.ClearCache();
                Console.WriteLine("Binding added");
            }
            catch (Exception ex)
            {
                ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(error);
            }
        }
Example #9
0
        public void ExpandSimpleAttributeSVReference()
        {
            AcmaSchemaAttribute   attribute    = ActiveConfig.DB.GetAttribute("supervisor");
            AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person");
            string declarationString           = "{supervisor}";
            AttributeDeclarationParser p       = new AttributeDeclarationParser(declarationString);
            AttributeDeclaration       target  = p.GetAttributeDeclaration();


            CSEntryChange sourceObject = CSEntryChange.Create();

            sourceObject.ObjectModificationType = ObjectModificationType.Add;
            sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, new Guid("8c3cbf4e-5216-4a04-9140-b0b11020fa4c")));

            object value = target.Expand(sourceObject).First();

            if (value == null)
            {
                Assert.Fail("The declaration string did not return a value");
            }
            else if (!(value is Guid))
            {
                Assert.Fail("The declaration string returned the wrong data type");
            }
            else if ((Guid)value != new Guid("8c3cbf4e-5216-4a04-9140-b0b11020fa4c"))
            {
                Assert.Fail("The declaration string did not return the expected value");
            }
        }
Example #10
0
 public NewAcmaSchemaShadowObjectLinkViewModel(Window window, AcmaSchemaShadowObjectLinksViewModel linksViewModel)
     : base()
 {
     this.linksViewModel = linksViewModel;
     this.Commands.AddItem("Create", t => this.Create(window), t => this.CanCreate());
     this.shadowParentObjectClass = linksViewModel.ObjectClass.ShadowFromObjectClass;
 }
Example #11
0
        protected override void ProcessRecord()
        {
            Global.ThrowIfNotConnected(this);

            try
            {
                AcmaSchemaObjectClass shadowClass = ActiveConfig.DB.GetObjectClass(this.ShadowObjectClass);

                if (!shadowClass.IsShadowObject)
                {
                    throw new ArgumentException("The specified object class is not a shadow object class");
                }

                AcmaSchemaObjectClass parentClass           = shadowClass.ShadowFromObjectClass;
                AcmaSchemaAttribute   provisioningAttribute = ActiveConfig.DB.GetAttribute(this.ProvisioningAttribute, parentClass);
                AcmaSchemaAttribute   referenceAttribute    = ActiveConfig.DB.GetAttribute(this.ReferenceAttribute, parentClass);

                ActiveConfig.DB.CreateShadowLink(shadowClass, provisioningAttribute, referenceAttribute, this.Name);
                // ActiveConfig.DB.ClearCache();
            }
            catch (Exception ex)
            {
                ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(error);
            }
        }
Example #12
0
 public CSEntryChangeViewModel(CSEntryChange model)
     : base(model)
 {
     this.Commands.AddItem("Delete", t => this.Delete());
     this.IgnorePropertyHasChanged.Add("DisplayName");
     this.objectClass = ActiveConfig.DB.GetObjectClass(model.ObjectType);
 }
Example #13
0
        public void ExpandSimpleAttributeSVBinary()
        {
            AcmaSchemaAttribute   attribute    = ActiveConfig.DB.GetAttribute("objectSid");
            AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person");
            string declarationString           = "{objectSid}";
            AttributeDeclarationParser p       = new AttributeDeclarationParser(declarationString);
            AttributeDeclaration       target  = p.GetAttributeDeclaration();

            CSEntryChange sourceObject = CSEntryChange.Create();

            sourceObject.ObjectModificationType = ObjectModificationType.Add;
            sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, new byte[] { 0, 1, 2, 3, 4 }));

            object value = target.Expand(sourceObject).First();

            if (value == null)
            {
                Assert.Fail("The declaration string did not return a value");
            }
            else if (!(value is byte[]))
            {
                Assert.Fail("The declaration string returned the wrong data type");
            }
            else if (!((byte[])value).SequenceEqual(new byte[] { 0, 1, 2, 3, 4 }))
            {
                Assert.Fail("The declaration string did not return the expected value");
            }
        }
Example #14
0
        /// <summary>
        /// Returns any deleted objects in the database that match the resurrection criteria
        /// </summary>
        /// <param name="csentryChange">The CSEntryChange object representing the object being added to the database</param>
        /// <param name="dc">The DBDataContext in use on this thread</param>
        /// <returns>An MAObject matching the resurrection criteria, or null if no matching object was found</returns>
        private static MAObjectHologram GetResurrectionObject(CSEntryChange csentryChange)
        {
            AcmaSchemaObjectClass objectClass = null;

            if (csentryChange.ObjectType != null)
            {
                objectClass = ActiveConfig.DB.GetObjectClass(csentryChange.ObjectType);
            }

            MAObjectHologram existingObject = ActiveConfig.DB.GetMAObjectOrDefault(csentryChange.DN, objectClass);

            if (existingObject != null)
            {
                return(existingObject);
            }

            if (!ActiveConfig.DB.GetObjectClass(csentryChange.ObjectType).AllowResurrection)
            {
                return(null);
            }

            if (!ActiveConfig.XmlConfig.ClassConstructors.Contains(csentryChange.ObjectType))
            {
                return(null);
            }

            DBQueryGroup parameters = ActiveConfig.XmlConfig.ClassConstructors[csentryChange.ObjectType].ResurrectionParameters;

            if (parameters == null || parameters.DBQueries == null || parameters.DBQueries.Count == 0)
            {
                return(null);
            }

            return(ActiveConfig.DB.GetResurrectionObject(parameters, csentryChange));
        }
Example #15
0
        public UnitTestStepObjectCreationViewModel(UnitTestStepObjectCreation model)
            : base(model)
        {
            this.typedModel = model;
            AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass(model.ObjectClassName);

            this.AttributeChanges = new AttributeChangesViewModel(model.CSEntryChange.AttributeChanges, model.CSEntryChange.ObjectModificationType, objectClass, () => this.GetAllowedReferenceObjects());
        }
 public ValueDeclarationsViewModel(IList <ValueDeclaration> model, AcmaSchemaObjectClass objectClass)
     : base()
 {
     this.typedModel  = model;
     this.objectClass = objectClass;
     this.SetCollectionViewModel((IList)model, t => this.ViewModelResolver(t));
     this.NewItemPlaceholderPosition = System.ComponentModel.NewItemPlaceholderPosition.AtEnd;
 }
Example #17
0
 public AcmaSchemaShadowObjectLinksViewModel(IBindingList model, AcmaSchemaObjectClass objectClass)
     : base()
 {
     this.model = model;
     this.SetCollectionViewModel(model, t => this.ViewModelResolver(t));
     this.Commands.AddItem("AddLink", t => this.CreateLink());
     this.objectClass = objectClass;
     this.IgnorePropertyHasChanged.Add("DisplayName");
 }
Example #18
0
        /// <summary>
        /// Adds a new object to the database
        /// </summary>
        /// <param name="csentry">The CSEntryChange containing the new object and its attributes</param>
        /// <param name="dc">The DBDataContext in use on this thread</param>
        /// <param name="referenceRetryRequired">A value indicating whether a reference update failed due to a missing object and needs to be retried after all other CSEntryChanges have been processed</param>
        /// <returns>A list of anchor attributes for the new object</returns>
        private static IList <AttributeChange> PerformCSEntryExportAdd(CSEntryChange csentry, out bool referenceRetryRequired)
        {
            if (csentry.ObjectType == null)
            {
                throw new InvalidOperationException("No object class was specified for CSEntryChange with DN " + csentry.DN);
            }

            AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass(csentry.ObjectType);
            bool             isUndeleting     = false;
            MAObjectHologram hologram;
            Guid             guidFromDn = new Guid(csentry.DN);

            if (objectClass.IsShadowObject)
            {
                hologram = CSEntryExport.ExportShadowObject(csentry);
            }
            else
            {
                hologram = GetResurrectionObject(csentry);

                if (hologram == null)
                {
                    hologram = ActiveConfig.DB.CreateMAObject(guidFromDn, csentry.ObjectType);
                }
                else
                {
                    Logger.WriteLine("Resurrecting object with ID: " + hologram.ObjectID.ToString());
                    isUndeleting = true;

                    if (hologram.ObjectID != guidFromDn)
                    {
                        Logger.WriteLine("Re-anchoring object with new ID: " + csentry.DN);
                        ActiveConfig.DB.ChangeMAObjectId(hologram.ObjectID, guidFromDn, true);
                        hologram = ActiveConfig.DB.GetMAObject(guidFromDn, objectClass);
                    }

                    csentry = CSEntryChangeExtensions.ConvertCSEntryChangeAddToUpdate(csentry);
                }
            }

            AttributeChange        anchorChange  = AttributeChange.CreateAttributeAdd("objectId", csentry.DN);
            List <AttributeChange> anchorChanges = new List <AttributeChange>()
            {
                anchorChange
            };

            if (!hologram.ObjectClass.IsShadowObject)
            {
                // shadow objects must be provisioned by their parent object, which automatically calls the Commit method
                hologram.CommitCSEntryChange(csentry, isUndeleting);
            }

            referenceRetryRequired = hologram.ReferenceRetryRequired;

            return(anchorChanges);
        }
        public void ReferenceLookupUseAllResults()
        {
            ReferenceLookupConstructor constructor = new ReferenceLookupConstructor();

            constructor.Attribute            = ActiveConfig.DB.GetAttribute("displayNameSharers");
            constructor.MultipleResultAction = MultipleResultAction.UseAll;
            constructor.QueryGroup           = new DBQueryGroup()
            {
                Operator = GroupOperator.All
            };
            constructor.QueryGroup.DBQueries.Add(new DBQueryByValue(ActiveConfig.DB.GetAttribute("displayName"), ValueOperator.Equals, ActiveConfig.DB.GetAttribute("displayName")));

            Guid object1Id = Guid.NewGuid();
            Guid object2Id = Guid.NewGuid();
            Guid object3Id = Guid.NewGuid();
            AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass("person");

            try
            {
                MAObjectHologram object1 = ActiveConfig.DB.CreateMAObject(object1Id, "person");
                object1.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                object1.CommitCSEntryChange();

                MAObjectHologram object2 = ActiveConfig.DB.CreateMAObject(object2Id, "person");
                object2.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                object2.CommitCSEntryChange();

                MAObjectHologram object3 = ActiveConfig.DB.CreateMAObject(object3Id, "person");
                object3.SetAttributeValue(ActiveConfig.DB.GetAttribute("displayName"), "My Display Name");
                constructor.Execute(object3);
                object3.CommitCSEntryChange();

                object3 = ActiveConfig.DB.GetMAObject(object3Id, objectClass);
                AttributeValues values = object3.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("displayNameSharers"));

                if (values.IsEmptyOrNull)
                {
                    Assert.Fail("The constructor did not create any results");
                }

                if (!values.ContainsAllElements(new List <object> {
                    object1Id, object2Id
                }))
                {
                    Assert.Fail("The constructor did not create the correct values");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(object1Id);
                ActiveConfig.DB.DeleteMAObjectPermanent(object2Id);
                ActiveConfig.DB.DeleteMAObjectPermanent(object3Id);
            }
        }
Example #20
0
        private void OnObjectClassPropertyChanged(object oldValue, object newValue)
        {
            AcmaSchemaObjectClass oldClass = oldValue as AcmaSchemaObjectClass;
            AcmaSchemaObjectClass newClass = newValue as AcmaSchemaObjectClass;

            if (oldClass != null)
            {
                oldClass.Mappings.ListChanged -= Mappings_ListChanged;
            }

            if (newClass != null)
            {
                newClass.Mappings.ListChanged += Mappings_ListChanged;
            }
        }
        public void AddMapping(AcmaSchemaObjectClass objectClass, AcmaSchemaAttribute attribute, AcmaSchemaAttribute inheritanceSource, AcmaSchemaObjectClass inheritanceSourceObjectClass, AcmaSchemaAttribute inheritedAttribute)
        {
            AcmaSchemaMapping mapping;

            if (inheritanceSource == null && inheritedAttribute == null)
            {
                mapping = ActiveConfig.DB.CreateMapping(objectClass, attribute, this.model);
            }
            else
            {
                mapping = ActiveConfig.DB.CreateMapping(objectClass, attribute, inheritanceSource, inheritanceSourceObjectClass, inheritedAttribute, this.model);
            }

            this.Add(mapping);
        }
        public AttributeChangesViewModel(IList <AttributeChange> model, ObjectModificationType objectModificationType, AcmaSchemaObjectClass objectClass, Func <IEnumerable <UnitTestStepObjectCreation> > allowedReferenceObjects)
            : base()
        {
            this.objectClass             = objectClass;
            this.allowedReferenceObjects = allowedReferenceObjects;
            this.objectModificationType  = objectModificationType;
            this.Commands.AddItem("AddAttributeChange", t => this.AddAttributeChange(), t => this.CanAddAttributeChange());
            ActiveConfig.DB.OnAttributeRenamed += DB_OnAttributeRename;
            ActiveConfig.DB.OnAttributeDeleted += DB_OnAttributeDeleted;
            ActiveConfig.DB.OnBindingDeleted   += DB_OnBindingDeleted;

            this.SetCollectionViewModel(model, t => this.ViewModelResolver(t));

            if (this.Count > 0)
            {
                this.FirstOrDefault().IsSelected = true;
            }
        }
        protected override void ProcessRecord()
        {
            Global.ThrowIfNotConnected(this);

            try
            {
                AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass(this.Name);
                objectClass.AllowResurrection = this.IsUndeletable;
                ActiveConfig.DB.Commit();
                ActiveConfig.DB.ClearCache();
                Console.WriteLine("Object class modified");
            }
            catch (Exception ex)
            {
                ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(error);
            }
        }
Example #24
0
        public void ExpandSimpleAttributeSVStringWithOptionalText2()
        {
            AcmaSchemaAttribute   attribute    = ActiveConfig.DB.GetAttribute("mail");
            AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person");
            string declarationString           = "[{mail}.au]";
            AttributeDeclarationParser p       = new AttributeDeclarationParser(declarationString);
            AttributeDeclaration       target  = p.GetAttributeDeclaration();

            CSEntryChange sourceObject = CSEntryChange.Create();

            sourceObject.ObjectModificationType = ObjectModificationType.Add;

            IList <object> value = target.Expand(sourceObject);

            if (value != null && value.Count > 0)
            {
                Assert.Fail("The declaration string unexpectedly returned a value");
            }
        }
Example #25
0
        protected override void ProcessRecord()
        {
            Global.ThrowIfNotConnected(this);

            try
            {
                AcmaSchemaObjectClass sourceObjectClass = ActiveConfig.DB.GetObjectClass(this.SourceObjectClass);
                AcmaSchemaAttribute   sourceAttribute   = ActiveConfig.DB.GetAttribute(this.SourceAttribute);
                AcmaSchemaObjectClass targetObjectClass = ActiveConfig.DB.GetObjectClass(this.TargetObjectClass);
                AcmaSchemaAttribute   targetAttribute   = ActiveConfig.DB.GetAttribute(this.TargetAttribute);

                ActiveConfig.DB.CreateReferenceLink(sourceObjectClass, sourceAttribute, targetObjectClass, targetAttribute);

                ActiveConfig.DB.ClearCache();
                Console.WriteLine("Reference link created");
            }
            catch (Exception ex)
            {
                ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(error);
            }
        }
Example #26
0
        public void ThrowOnReferencedAttribute()
        {
            AcmaSchemaObjectClass schemaObject = ActiveConfig.DB.GetObjectClass("person");
            AcmaSchemaAttribute   attribute    = ActiveConfig.DB.GetAttribute("supervisor");
            string declarationString           = "{supervisor->unixGid}";
            AttributeDeclarationParser p       = new AttributeDeclarationParser(declarationString);
            AttributeDeclaration       target  = p.GetAttributeDeclaration();

            CSEntryChange sourceObject = CSEntryChange.Create();

            sourceObject.ObjectModificationType = ObjectModificationType.Add;
            sourceObject.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, Guid.NewGuid()));

            try
            {
                object value = target.Expand(sourceObject).First();

                Assert.Fail("The expansion did not trigger an exception");
            }
            catch (NotSupportedException)
            { }
        }
Example #27
0
        public void ExportCSEntryChangeDelete()
        {
            Guid          id      = Guid.NewGuid();
            CSEntryChange csentry = CSEntryChange.Create();

            csentry.DN = id.ToString();
            csentry.ObjectModificationType = ObjectModificationType.Add;
            csentry.ObjectType             = "person";
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mail", "*****@*****.**"));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mailAlternateAddresses", new List <object> {
                "*****@*****.**", "*****@*****.**"
            }));

            try
            {
                bool refretry;
                CSEntryExport.PutExportEntry(csentry, out refretry);

                csentry    = CSEntryChange.Create();
                csentry.DN = id.ToString();
                csentry.ObjectModificationType = ObjectModificationType.Delete;
                csentry.ObjectType             = "person";
                AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass("person");

                CSEntryExport.PutExportEntry(csentry, out refretry);

                MAObjectHologram sourceObject = ActiveConfig.DB.GetMAObject(id, objectClass);

                if (sourceObject.DeletedTimestamp == 0)
                {
                    Assert.Fail("The object was not deleted");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(id);
            }
        }
Example #28
0
        protected override void ProcessRecord()
        {
            Global.ThrowIfNotConnected(this);

            try
            {
                AcmaSchemaObjectClass shadowFromClass = null;

                if (this.ShadowFrom != null)
                {
                    shadowFromClass = ActiveConfig.DB.GetObjectClass(this.ShadowFrom);
                }

                ActiveConfig.DB.CreateObjectClass(this.Name, this.IsUndeletable, shadowFromClass);
                ActiveConfig.DB.ClearCache();
                Console.WriteLine("Object class added");
            }
            catch (Exception ex)
            {
                ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(error);
            }
        }
        protected override void ProcessRecord()
        {
            Global.ThrowIfNotConnected(this);

            try
            {
                if (this.ShouldProcess("Are you sure you want to delete this object class? This will delete all objects of this class"))
                {
                    if (this.Force || this.ShouldContinue("Are you sure you want to delete this object class? This will delete all objects of this class", "Confirm object class delete"))
                    {
                        AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass(this.Name);
                        ActiveConfig.DB.DeleteObjectClass(objectClass);
                        ActiveConfig.DB.Commit();
                        ActiveConfig.DB.ClearCache();
                        Console.WriteLine("Object class deleted");
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorRecord error = new ErrorRecord(ex, "UnknownError", ErrorCategory.NotSpecified, null);
                ThrowTerminatingError(error);
            }
        }
Example #30
0
        public void ExportCSEntryChangeAdd()
        {
            Guid          id      = Guid.NewGuid();
            CSEntryChange csentry = CSEntryChange.Create();

            csentry.DN = id.ToString();
            csentry.ObjectModificationType = ObjectModificationType.Add;
            csentry.ObjectType             = "person";
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mail", "*****@*****.**"));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("mailAlternateAddresses", new List <object> {
                "*****@*****.**", "*****@*****.**"
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("unixUid", 44L));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("expiryDates", new List <object>()
            {
                55L, 66L, 77L
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("directReports", new List <object>()
            {
                new Guid("{8FC92471-7835-4804-8BBB-0A5ED7078074}"), new Guid("{0EF7CC21-729E-4ED9-A3AF-8203796334C6}")
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("supervisor", new Guid("{2807ED76-E262-4EB4-ABD9-9629F3830F12}")));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("connectedToSap", true));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("dateTimeMV", new List <object>()
            {
                DateTime.Parse("2010-01-01"), DateTime.Parse("2011-01-01")
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("dateTimeSV", DateTime.Parse("2012-01-01")));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("objectSids", new List <object>()
            {
                new byte[] { 0, 1, 2, 3, 4, 5 }, new byte[] { 2, 4, 6, 8, 0 }
            }));
            csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("objectSid", new byte[] { 0, 1, 2, 3, 4 }));
            AcmaSchemaObjectClass objectClass = ActiveConfig.DB.GetObjectClass("person");

            try
            {
                bool refretry;
                CSEntryExport.PutExportEntry(csentry, out refretry);

                MAObjectHologram sourceObject = ActiveConfig.DB.GetMAObject(id, objectClass);

                if (sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("mail")).ValueString != "*****@*****.**")
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }

                if (sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("dateTimeSV")).ValueDateTime != DateTime.Parse("2012-01-01"))
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }

                if (sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("unixUid")).ValueLong != 44L)
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }

                if (sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("connectedToSap")).ValueBoolean != true)
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }

                if (!sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("objectSid")).ValueByte.SequenceEqual(new byte[] { 0, 1, 2, 3, 4 }))
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }

                if (sourceObject.GetSVAttributeValue(ActiveConfig.DB.GetAttribute("supervisor")).ValueGuid != new Guid("{2807ED76-E262-4EB4-ABD9-9629F3830F12}"))
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }

                if (!sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("mailAlternateAddresses")).ContainsAllElements(new List <object> {
                    "*****@*****.**", "*****@*****.**"
                }))
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }

                if (!sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("expiryDates")).ContainsAllElements(new List <object>()
                {
                    55L, 66L, 77L
                }))
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }

                if (!sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("dateTimeMV")).ContainsAllElements(new List <object>()
                {
                    DateTime.Parse("2010-01-01"), DateTime.Parse("2011-01-01")
                }))
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }

                if (!sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("directReports")).ContainsAllElements(new List <object>()
                {
                    new Guid("{8FC92471-7835-4804-8BBB-0A5ED7078074}"), new Guid("{0EF7CC21-729E-4ED9-A3AF-8203796334C6}")
                }))
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }

                if (!sourceObject.GetMVAttributeValues(ActiveConfig.DB.GetAttribute("objectSids")).ContainsAllElements(new List <object>()
                {
                    new byte[] { 0, 1, 2, 3, 4, 5 }, new byte[] { 2, 4, 6, 8, 0 }
                }))
                {
                    Assert.Fail("One or more attribute changes were not committed");
                }
            }
            finally
            {
                ActiveConfig.DB.DeleteMAObjectPermanent(id);
            }
        }