When you import objects from a connected system to the FIM Synchronization Service database (metaverse), the imported objects might have attribute values that are of a data type that you must convert to a different data type to be compatible with other objects in the metaverse. You can use a rules extension to convert the type of the attribute when it is imported into the metaverse.
Supported Conversions
Not all conversions between data types are supported. For example, you cannot convert an AttributeType data type into an AttributeType data type. The following table shows the supported conversions, where -> means "is converted to".
Original attribute type (Attrib.DataType property) | |||||
---|---|---|---|---|---|
Convert to: |
Binary |
Boolean |
Integer |
Reference |
String |
Binary |
Not necessary |
If true, -> 1; if false, -> 0. |
Supported |
Not supported |
Supported using Convert.FromBase64. |
Boolean |
If all bytes 0, -> false; else -> true. |
Not necessary |
If 0, -> false; else -> true. |
Not supported |
If "true" or "1", -> true; if "false" or "0", -> false; else not supported. |
Integer |
Throws exception if > 64 bits. |
If true, -> 1; if false, -> 0. |
Not necessary |
Not supported |
Supported using Integer.Parse(). |
Reference |
Not supported |
Not supported |
Not supported |
Not necessary |
Supported using CreateDN |
String |
Supported using Convert.ToBase64. |
If true, -> "true"; if false, -> "false". |
Supported |
Supported |
Not necessary |
The following examples show how to convert an integer attribute data type to a formatted string before it is imported into the metaverse.
Visual Basic | Copy Code |
---|---|
Public Sub MapAttributesForImport( _ ByVal FlowRuleName As String, _ ByVal csentry As CSEntry, _ ByVal mventry As MVEntry) _ Implements IMASynchronization.MapAttributesForImport Select Case FlowRuleName Case "employeeStart" ' employeeStart is an integer representing a date and time. ' The format is YYYYMMDDHHmmSS, where YYYY is the year, ' MM is the month, DD is the day, HH is the hour, mm is ' the minute, and SS is the seconds. If (Not csentry("employeeStart").DataType = AttributeType.Integer) Then throw new MetadirectoryServicesException("employeeStart must be an integer") End If Dim startString, year, month, day, hour, min, sec As String ' Value always returns a string. startString = csentry("employeeStart").Value year = startString.Substring( 0, 4) month = startString.Substring( 4, 2) day = startString.Substring( 6, 2) hour = startString.Substring( 8, 2) min = startString.Substring(10, 2) sec = startString.Substring(12, 2) Dim dt as DateTime dt = Convert.ToDateTime(month + "/" + _ day + "/" + _ year + " " + _ hour + ":" + _ min + ":" + _ sec) ' Renders 20030903113029 as ' 9/3/2003 11:30 AM mventry("employeeStart").Value = dt.ToShortDateString() + dt.ToShortTimeString() Case Else Throw New EntryPointNotImplementedException() End Select End Sub |
C# | Copy Code |
---|---|
void IMASynchronization.MapAttributesForImport (string FlowRuleName, CSEntry csentry, MVEntry mventry) { switch(FlowRuleName) { case "employeeStart": // employeeStart is an integer representing a date and time. // The format is YYYYMMDDHHmmSS, where YYYY is the year, // MM is the month, DD is the day, HH is the hour, mm is // the minute, and SS is the seconds. if(csentry["employeeStart"].DataType != AttributeType.Integer) { throw new MetadirectoryServicesException("employeeStart must be an integer"); } // Value always returns a string. string startString = csentry["employeeStart"].Value; string year = startString.Substring( 0, 4); string month = startString.Substring( 4, 2); string day = startString.Substring( 6, 2); string hour = startString.Substring( 8, 2); string min = startString.Substring(10, 2); string sec = startString.Substring(12, 2); DateTime dt = Convert.ToDateTime(month + "/" + day + "/" + year + " " + hour + ":" + min + ":" + sec); // Renders 20030903113029 as // 9/3/2003 11:30 AM mventry["employeeStart"].Value = dt.ToShortDateString() + dt.ToShortTimeString(); break; default: throw new EntryPointNotImplementedException(); } } |