Calling AttributeChange.CreateAttributeAdd() on an attribute that does not exist or is not included in an objecttype does not genereate a NoSuchAttributeInObjectTypeException RRS feed

  • Question

  • Hi

    I'm building ECMA 2.1 agents and a stumbled on a problem. In earlier builds of R2 SP1 like 4.1.3114 you would get a NoSuchAttributeInObjectTypeException if you tried to call csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("ATTRNAME", "ATTRVALUE")); on an attribute retrieved from the datasource that doesn't exists in the MA or is not seleted. This seems to have been changed in build 4.1.3508? I recently upgraded my testenvironment and a customers environment and after that upgrade I no longer get this NoSuchAttributeInObjectTypeException. Instead I am allowed to add this attribute and it's value to the csentry, but when the syncengine continues to process this further I get this exception:

    The server encountered an unexpected error while performing an operation for a management agent.


     "Microsoft.MetadirectoryServices.NoSuchAttributeInObjectTypeException: Attribute "HiddenFromAddressListsEnabled" is not usable with the object type in question.

       at Microsoft.MetadirectoryServices.Impl.Ecma2ConversionServices.AddAttributeToDImage(CDImage* pdimage, String attributeName, AttributeModificationType attributeModificationType, IList`1 attributeValueChanges, Int32 escapeReferenceDNValues)

    So now I have no possibility to handle this.....

    Does anyone have any thoughts or insight on this? Is this a bug or is there a reason for changing this behavour? How should we handle this scenario in ECMA code? Even if I would search the schema I have no way of determine if an attribute is selected, or is there?



    Wednesday, May 7, 2014 2:27 PM

All replies

  • So I thought I would share a solution if others get the same problem.

    I opened up a case with PSS about this and they could reproduce the exact error and verified that this behavour indeed have been changed for newer builds. The workaround they suggested was to check the schema to make sure that an attribute exists before adding it in to an CSEntry.

    The way I solved it was to declare a list object and the loop the schema and fill the list with the detected attributes. Then I added an extra check before proceeding with adding in the attribute to the CSEntry with a check that the attribute exists in the list/schema.

    Something like:

    private List<string> _schemaAttributes;

    // We add in the attributes in the schema to a searchable list

                _schemaAttributes = new List<string>();

                foreach (SchemaAttribute attribute in types.Types.First().Attributes)


    // We determine that this is an existing attribute we try to add to avoid exceptions.

                                if (_schemaAttributes.Contains(propName))


    // Standard single value attribute

                                     if (!String.IsNullOrWhiteSpace(propValue.ToString()))

                                     csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(propName, propValue.ToString()));



    Wednesday, September 10, 2014 8:34 AM