Microsoft Identity Integration Server 2003 Developer Reference

Example: Manual Precedence Using the Last Contributing Management Agent

The following example shows you 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 is allowed to change the attribute. Other management agents cannot change the attribute value.

[Visual Basic .NET]
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
[C#]
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

Manual Precedence Examples