次の方法で共有


Rules Extensions - MapAttributesForImport

Update 6/23/2017 (working on Code formatting for presentation)

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 the following post I 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.

 

Now lets look deeper into MapAttributesForImport, the following code snippet includes helper functions which we will point out in the follow up post. For this post we will focus on only the section that is used to Map Attributes for Import or more accurately said the “IMASynchronization.MapAttributesForImport” method , the goal is to provide some explanation of how to build your Custom MA Extension one method at a time.

 

        void IMASynchronization.MapAttributesForImport(string FlowRuleName, CSEntry csentry, MVEntry mventry)
{
string csAttrib;
string mvAttrib;
long dtInt;
string targetFormat;
string sourceFormat;

//
// TODO: write your import attribute flow code
//
switch (FlowRuleName)
{
case "getDate":
mvAttrib = "deprovisionDate";
if (mventry.ConnectedMAs[ADMA1].Connectors.Count == 0)
{
if (mventry[mvAttrib].IsPresent && !string.IsNullOrWhiteSpace(mvAttrib))
{
DateTime depoDate;
if (!DateTime.TryParse(mventry[mvAttrib].Value, out depoDate))
{
//mventry ["deprovisionDate"].Value = DateTime.Now.AddDays(90).ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.000'");
mventry[mvAttrib].Value = DateTime.Now.AddDays(90).ToString("yyyy-MM-ddTHH:mm:ss.000");
}
else
{
mventry[mvAttrib].Value = DateTime.Now.AddDays(90).ToString("yyyy-MM-ddTHH:mm:ss.000");
}

}
else
{
mventry[mvAttrib].Value = DateTime.Now.AddDays(90).ToString("yyyy-MM-ddTHH:mm:ss.000");
}
}
break;

case "removeDate":
mvAttrib = "deprovisionDate";
if (mventry.ConnectedMAs[ADMA1].Connectors.Count == 1)
{
if (mventry[mvAttrib].IsPresent)
{
mventry[mvAttrib].Values.Clear();
}
}
break;

case "employeeEndDate":
csAttrib = "accountExpires";
mvAttrib = "employeeEndDate";
dtInt = csentry[csAttrib].IntegerValue;
//targetFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.000'";
targetFormat = "yyyy-MM-ddTHH:mm:ss.000";
//targetFormat = "M/d/yyyy h:mm tt";
sourceFormat = string.Empty;
GetDateString(csentry, mventry, dtInt, mvAttrib, sourceFormat, targetFormat);
break;

case "pwdLastSet":
csAttrib = "pwdLastSet";
mvAttrib = "pwdLastSet";
dtInt = csentry[csAttrib].IntegerValue;
targetFormat = "M/d/yyyy h:mm tt";
sourceFormat = string.Empty; ;
if (csentry[csAttrib].IsPresent && csentry[csAttrib].IntegerValue != 0)
GetDateString(csentry, mventry, dtInt, mvAttrib, sourceFormat, targetFormat);
///mventry[mvAttrib].Value = ConvertFileTimeToFimTimeStamp(csentry[csAttrib].IntegerValue);
else
mventry[mvAttrib].Delete();
break;

case "pwdExpires":
csAttrib = "pwdLastSet";
mvAttrib = "pwdExpires";
dtInt = csentry[csAttrib].IntegerValue;
targetFormat = "M/d/yyyy h:mm tt";
sourceFormat = string.Empty;
if (csentry[csAttrib].IsPresent && csentry[csAttrib].IntegerValue != 0)
GetDateString(csentry, mventry, dtInt, mvAttrib, sourceFormat, targetFormat, 180);
///mventry[mvAttrib].Value = ConvertFileTimeToFimTimeStamp(csentry[csAttrib].IntegerValue);
else
mventry[mvAttrib].Delete();
break;

case "lastLogonTimestamp":
csAttrib = "lastLogonTimestamp";
mvAttrib = "lastLogonTimestamp";
dtInt = csentry[csAttrib].IntegerValue;
targetFormat = "M/d/yyyy h:mm tt";
sourceFormat = string.Empty;
if (csentry[csAttrib].IsPresent && csentry[csAttrib].IntegerValue != 0)
GetDateString(csentry, mventry, dtInt, mvAttrib, sourceFormat, targetFormat);
//mventry[mvAttrib].Value = ConvertFileTimeToFimTimeStamp(csentry[csAttrib].IntegerValue);
else
mventry[mvAttrib].Delete();
break;

case "createdDate":
csAttrib = "whenCreated";
mvAttrib = "createDate";
string dateStr = csentry[csAttrib].StringValue;
targetFormat = "M/dd/yyyy h:mm:ss tt";
sourceFormat = "yyyyMMddHHmmss.0Z";
GetDateString(csentry, mventry, dateStr, mvAttrib, sourceFormat, targetFormat);
break;
case "objectSidString":
string objectSidString = ConvertSidToString(csentry["objectSid"].BinaryValue);
mventry["objectSidSTring"].StringValue = objectSidString;
break;

}
}

See Helper Function Posting

 

NOTE:

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 See Management Agent Advanced Attribute Flows Post.

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

 

Questions? Comments? Love FIM/MIM so much you can’t even stand it?

EMAIL US!

>WE WANT TO HEAR FROM YOU<

## https://blogs.msdn.microsoft.com/connector_space# #