Partager via


How to: Modify Attribute Values Using the Last Contributing Management Agent

The following examples show how to set the value for an attribute that is configured for manual precedence only if a specified management agent changes the value. The first time the attribute is set, the example sets the attribute. From then on, only the management agent that first set the attribute can change the attribute. Other management agents cannot change the attribute value.

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

    Select Case FlowRuleName
        Case "Given Name Precedence"
            Const MVAttributeName = "cn"
            Const CSAttributeName = "displayName"
            If mventry(MVAttributeName).IsPresent Then

                ' Only allow the original management agent to modify the attribute.
                If mventry(MVAttributeName).LastContributingMA.Equals(csentry.MA) Then
                    mventry(MVAttributeName).Value = csentry(CSAttributeName).Value
                Else
                    Throw New DeclineMappingException
                End If

            Else

                ' This is the first time the attribute is being set.
                mventry(MVAttributeName).Value = csentry(CSAttributeName).Value
            End If
    End Select
End Sub
void IMASynchronization.MapAttributesForImport(string FlowRuleName, 
    CSEntry csentry, 
    MVEntry mventry)
{
    switch(FlowRuleName)
    {
        case "Given Name Precedence":
            string MVAttributeName = "cn";
            string CSAttributeName = "displayName";
            
            if(mventry[MVAttributeName].IsPresent)
            {

                // Only allow the original management agent to modify the attribute.
                if(mventry[MVAttributeName].LastContributingMA.Equals(csentry.MA))
                {
                    mventry[MVAttributeName].Value = csentry[CSAttributeName].Value;
                }
                else
                {
                    throw new DeclineMappingException();
                }
            }
            else
            {

                // This is the first time the attribute is being set.
                mventry[MVAttributeName].Value = csentry[CSAttributeName].Value;
            }
            break;
    }
}

See Also

Concepts

Manual Precedence Examples