Rules Extensions – MapAttributesForImport


Updated3/25/2016

In this post we will focus on the following section of the Management Agent Rules Extension.

 

In the Synchronization Service click on the MA that you wish to map the Attribute Flows to the above Code.

In this example we were mapping the accountExpires attribute from an object in the Connector Space to an object in the Metaverse converting the value from an integer value to its String equivalent.

Lets take a look at a User Object in Active Directory who has the accountExpires attribute set.

 

this is what it looks like in the ADUC Gui but if we look at the actual value in ADSI Edit or on the Attribute Editor Tab of the Object in ADUC

 

so the actual value within AD is 131026644000000000

When syncing this Value with the FIM / MIM Portal which needs this attribute to be converted to its Date Time Format we use this MapAttributesForImport post as an example to achieve this task.

## Additional information on “IMASynchronization.MapAttributesForImport Method”  can be located here

 

void IMASynchronization.MapAttributesForImport( string FlowRuleName, CSEntry csentry, MVEntry mventry)
        {
            //
            // TODO: write your import attribute flow code
            //
            throw new EntryPointNotImplementedException();
        }

 

In a previous post we detailed 2 Way Account Expires Rules Extension , which utilized the “IMASynchronization.MapAttributesForImport Method” but also focused on the importance of equal precedence and the “IMASynchronization.MapAttributesForExport” method. In this post we will focus on the actual “IMASynchronization.MapAttributesForImportmethod as opposed to an individual function such as accountExpires to employeeEndDate.

The following is copied from a previous post used for reference Rules Extension -MAExtension

 

void IMASynchronization.MapAttributesForImport(string FlowRuleName, CSEntry csentry, MVEntry mventry)
{
//
// TODO: write your import attribute flow code
//
switch (FlowRuleName)
{
#region connected->mv.person:GetDate
case “connected->mv.person:getdate”:
if (mventry.ConnectedMAs[“Contoso ADMA”].Connectors.Count == 0)
{
if (mventry[“deprovisionDate”].IsPresent)
{
DateTime depoDate;
if(!DateTime.TryParse(mventry[“deprovisionDate”].Value, out depoDate))
{
//mventry [“deprovisionDate”].Value = DateTime.Now.AddDays(90).ToString(“yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss’.000′”);
mventry[“deprovisionDate”].Value = DateTime.Now.AddDays(90).ToString(“yyyy-MM-ddTHH:mm:ss”);
}
else
{
mventry[“deprovisionDate”].Value = DateTime.Now.AddDays(90).ToString(“yyyy-MM-ddTHH:mm:ss”);
}

}
}
break;
#endregion // connected ->mv.person.GetDate
#region connected->mv.person:RemoveDate
case “connected->mv.person:RemoveDate”:
if (mventry.ConnectedMAs[“Contoso ADMA”].Connectors.Count == 1)
{
if (mventry[“deprovisionDate”].IsPresent)
{
mventry[“deprovisionDate”].Values.Clear();
}
}
break;
#endregion // connected ->mv.person.GetDate
#region cd.user:accountExpires->mv.person:employeeEndDate
case “cd.user:accountExpires->mv.person:employeeEndDate”:
if (csentry[“accountExpires”].IntegerValue == 0 || csentry[“accountExpires”].IntegerValue == 9223372036854775807)
{
// This is a special condition, do not contribute and delete any current value
mventry[“employeeEndDate”].Delete();
}
else
{
DateTime dtFileTime = DateTime.FromFileTime(csentry[“accountExpires”].IntegerValue);
mventry[“employeeEndDate”].Value =
dtFileTime.ToString(“yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss’.000′”);
}
break;
#endregion // cd.user:accountExpires->mv.person:employeeEndDate
#region cd.user:pwdLastSet->mv.person:pwdLastSet
case “cd.user:pwdLastSet->mv.person:pwdLastSet”:
if (csentry[“pwdLastSet”].IsPresent && csentry[“pwdLastSet”].IntegerValue != 0)
mventry[“pwdLastSet”].Value = ConvertFileTimeToFimTimeStamp(csentry[“pwdLastSet”].IntegerValue);
else
mventry[“pwdLastSet”].Delete();
break;
#endregion // cd.user:pwdLastSet->mv.person:pwdLastSet
#region cd.user:lastLogonTimestamp->mv.person:lastLogonTimestamp
case “cd.user:lastLogonTimestamp->mv.person:lastLogonTimestamp”:
if (csentry[“lastLogonTimestamp”].IsPresent && csentry[“lastLogonTimestamp”].IntegerValue != 0)
mventry[“lastLogonTimestamp”].Value = ConvertFileTimeToFimTimeStamp(csentry[“lastLogonTimestamp”].IntegerValue);
else
mventry[“lastLogonTimeStampString”].Delete();
break;
#endregion // cd.user:lastLogonTimestamp->mv.person:lastLogonTimestamp
}
}
private static string ConvertFileTimeToFimTimeStamp(long fileTime)
{
return DateTime.FromFileTimeUtc(fileTime).ToString(“yyyy-MM-ddTHH:mm:ss.000”);
}

After you have you code compiled for all attribute flows that will call one of the functions in this method be sure to select the flow direction of Import and use the case when setting the Flow rule name: which is within the Advanced mapping type.

Additionally be sure to select all attributes from the Data Source that the function uses to build the value for the metaverse attribute.

 

Comments (0)