Partager via


How to: Merge Multiple Attributes from the Same Management Agent

The following examples show how to merge the value of the samAccountName and mailNickName attributes from multiple Forefront Identity Manager Synchronization Service (FIM Synchronization Service) database (metaverse) connector space objects of the same management agent to the same MVEntry object. If the multi-valued attribute exists, the connector space attribute values are merged into the samAccountName and mailNickName attributes of the metaverse object.

Note

If your management agents link multiple connector space objects to the same metaverse object, you must explicitly assign values from the connector space object attributes to the metaverse object attributes, such as the samAccountName and mailNickName attributes in the following example.

Before you use this rule extension, you must modify the metaverse attribute flow precedence rules in the Metaverse Design window so that it allows manual precedence rules to be applied to this attribute.

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

   Select Case FlowRuleName

      Case "IAF_samAccountName"
         Merge(csentry, mventry, "samAccountName", "samAccountName")

      Case "IAF_mailNickName"
         Merge(csentry, mventry, "mailNickName", "mailNickName")

      Case Else

         ' TODO: Remove the following statement and add your code here.
         Throw New EntryPointNotImplementedException

   End Select

End Sub

Public Sub Merge(ByVal csentry As CSEntry, ByRef mventry As MVEntry, _
                 ByVal csattr As String, ByVal mvattr As String)

    If csentry(csattr).IsPresent And csentry(csattr).IsMultivalued = True Then

        If Not csentry(csattr).Values.Count = 0 Then
            mventry(mvattr).Values.Add(csentry(csattr).Values)
        End If

    End If

End Sub
void IMASynchronization.MapAttributesForImport( string FlowRuleName, 
                                                CSEntry csentry, 
                                                MVEntry mventry)
{
   switch (FlowRuleName)
   {
      case "IAF_samAccountName" :
         Merge(csentry, ref mventry, "samAccountName", "samAccountName");
         break;
         
      case "IAF_mailNickName" :
         Merge(csentry, ref mventry, "mailNickName", "mailNickName");
         break;

      default :
         throw new EntryPointNotImplementedException();
   }
}

void Merge(CSEntry csentry, ref MVEntry mventry, string csattr, string mvattr)
{
   if (csentry[csattr].IsPresent && true == csentry[csattr].IsMultivalued)
   {
      mventry[mvattr].Values.Add(csentry[csattr].Value);
   }
}

See Also

Reference

MVEntry

Concepts

Manual Precedence Examples