Share via


How to: Handle Attribute Value Accumulation

An MVEntry object can have an attribute that contains multiple values that are imported from several connected CSEntry objects. When the attribute values from the connected CSEntry objects are imported into the Forefront Identity Manager Synchronization Service (FIM Synchronization Service) database (metaverse), the values are added to the appropriate MVEntry object attribute.

When the attributes in the connected CSEntry objects are changed and then imported into the MVEntry object, the new values are added to the existing list of attribute values, which causes them to accumulate several values. With the addition of new values, some of the existing values may become obsolete. If many changes occur, the MVEntry object can have several incorrect values in the multi-valued attributes. In addition, the list of values can become large and unwieldy.

There are two solutions for this problem:

  • Use accumulation of values only with attributes that remain static.

  • Use a rules extension to delete the existing values and import the new and remaining correct values back into the attribute. By deleting and importing, you can make sure that the values in the multi-valued attribute are correct.

These code examples suggest a way to use a rules extension to delete existing values and import the new and remaining correct values during a delta import run. The MVEntry object has an attribute called otherMailbox that accepts values from all connected CSEntry objects that have a mail attribute. In this example, there are several connected directories that contain a mail attribute that has values that must be flowed into the metaverse.

When a flow rule named "Mail to Other Mailboxes" is used, the existing attribute values are deleted, and the mail attribute value from all connected directories, including the one with a new value, are imported into the otherMailbox attribute.

The following examples show how to handle attribute value accumulation.

Public Sub MapAttributesForImport(ByVal FlowRuleName As String, _
    ByVal csentry As CSEntry, _
    ByVal mventry As MVEntry) _
    Implements IMASynchronization.MapAttributesForImport
    Dim ConnectedManagementAgent As ConnectedMA
    Dim ConnectorSpaceEntry As CSEntry

    Select Case (FlowRuleName)

        Case "Mail to Other Mailboxes"
            Dim csAttr As String

            ' Clear all of the "otherMailbox" attribute values from the MV object.
            mventry("otherMailbox").Delete()

            ' Enumerate all of the connectors and add the "mail" attribute for each 
            ' one to the "otherMailbox" attribute of the MV entry. The set of existing 
            ' connectors includes the connector represented by csentry.
            For Each ConnectedManagementAgent In mventry.ConnectedMAs
                If ConnectedManagementAgent.Name = "MA1" Then
                    csAttr = "email"
                ElseIf ConnectedManagementAgent.Name = "MA2" Then
                    csAttr = "mail"
                End If
                For Each ConnectorSpaceEntry In ConnectedManagementAgent.Connectors
                    Try
                        If ConnectorSpaceEntry(csAttr).IsPresent Then
                            mventry("otherMailbox").Values.Add(ConnectorSpaceEntry(csAttr).Value)
                        End If
                    Catch attrEx As NoSuchAttributeException

                        ' The NoSuchAttributeException exception will be thrown if 
                        ' the "mail" attribute is not defined for the CSEntry object. 
                        ' In this case, just handle the exception and continue.
                    End Try
                Next
            Next

        Case Else
            Throw New EntryPointNotImplementedException()

    End Select
End Sub
void IMASynchronization.MapAttributesForImport (string FlowRuleName, 
CSEntry csentry, MVEntry mventry)
{
    switch (FlowRuleName)
    {
        case "Mail to Other Mailboxes":
        {
            string csAttr = null;
            mventry[ "otherMailbox" ].Delete();
            foreach(ConnectedMA ConnectedManagementAgent in mventry.ConnectedMAs)
            {
                if( ConnectedManagementAgent.Name == "MA1" )
                csAttr = "email";
                else if ( ConnectedManagementAgent.Name == "MA2" )
                csAttr = "mail";
                foreach(CSEntry ConnectorSpaceEntry in ConnectedManagementAgent.Connectors)
                {
                    if(ConnectorSpaceEntry[csAttr].IsPresent)
                    {
                        mventry["otherMailbox"].Values.Add(ConnectorSpaceEntry[csAttr].Value);
                    }
                }
            }
            break;
        }
        default:
        {
            throw new EntryPointNotImplementedException();
        }
    }
}

See Also

Reference

CSEntry
MVEntry

Concepts

Manual Precedence Examples