IMAExtensible2FileExport.ReadExportFile Method
Delivers a file that contains objects to be exported into the connected system.
Namespace: Microsoft.MetadirectoryServices
Assembly: Microsoft.MetadirectoryServicesEx (in Microsoft.MetadirectoryServicesEx.dll)
Usage
'Usage
Dim instance As IMAExtensible2FileExport
Dim configParameters As KeyedCollection(Of String, ConfigParameter)
Dim types As Schema
Dim exportRunStep As ReadExportFileRunStep
instance.ReadExportFile(configParameters, types, exportRunStep)
Syntax
'Declaration
Sub ReadExportFile ( _
configParameters As KeyedCollection(Of String, ConfigParameter), _
types As Schema, _
exportRunStep As ReadExportFileRunStep _
)
void ReadExportFile (
KeyedCollection<string,ConfigParameter> configParameters,
Schema types,
ReadExportFileRunStep exportRunStep
)
void ReadExportFile (
KeyedCollection<String^, ConfigParameter^>^ configParameters,
Schema^ types,
ReadExportFileRunStep^ exportRunStep
)
void ReadExportFile (
KeyedCollection<String,ConfigParameter> configParameters,
Schema types,
ReadExportFileRunStep exportRunStep
)
function ReadExportFile (
configParameters : KeyedCollection<String,ConfigParameter>,
types : Schema,
exportRunStep : ReadExportFileRunStep
)
Parameters
- configParameters
Contains a collection of ConfigParameter objects.
- types
Contains a Schema that defines the management agent’s schema.
- exportRunStep
Contains a ReadExportFileRunStep object which contains: a string with the name of the text file that contains the objects to export to the system, full export of delta export, partition information.
Remarks
Use this method to create the intermediate file and call the connected data source to process the intermediate file. All data in Forefront Identity Manager Synchronization Service (FIM Synchronization Service) uses the Unicode character set. If the connected data source that receives the exported data requires data in a different character set, use this method to convert the Unicode data to the character set that is required by your connected data source.
Although this method is not called from import-only connected data source extensions, an error occurs if this method is not implemented in the extension. For an import-only connected data source extension, you can implement this method by throwing an EntryPointNotImplementedException exception.
Exceptions: Return values, Errors, and Exceptions
The following is an example of ReadExportFile:
public void ReadExportFile(KeyedCollection<string, ConfigParameter> configParameters,
Schema types,
ReadExportFileRunStep exportRunStep)
{
// We do not use all the configParameters, which contain connection
// details, in the sample but if one were to connect to a
// foreign system, they would use these parameters to do so.
//
StreamReader sr = new StreamReader(exportRunStep.FilePath, Encoding.Unicode);
string lineContents = null;
XmlWriterSettings xmlSettings = new XmlWriterSettings();
// Determine encoding from Configuration Parmeters
string encoding = configParameters["Export Encoding"].Value;
if (encoding.Equals("ASCII"))
{
xmlSettings.Encoding = Encoding.ASCII;
}
else if (encoding.Equals("UTF8"))
{
xmlSettings.Encoding = Encoding.UTF8;
}
else
{
xmlSettings.Encoding = Encoding.Unicode;
}
// Use a run step config paramater to control Xml declaration
string omitXmlDecl = configParameters["Omit Xml Declaration"].Value;
if (omitXmlDecl.Equals("1"))
{
xmlSettings.OmitXmlDeclaration = true;
}
// Begin XML file
m_xmlWriterExport = XmlTextWriter.Create(MAUtils.MAFolder + @"\sample_export.xml", xmlSettings);
m_xmlWriterExport.WriteStartElement(Nodes.Root);
m_xmlWriterExport.WriteAttributeString(Nodes.FullExport, (OperationType.Full == exportRunStep.ExportType) ? "true" : "false");
// Include partition DN
m_xmlWriterExport.WriteElementString(Nodes.PartitionDN, exportRunStep.StepPartition.DN);
// Read from export file and create XML file
while (null != (lineContents = sr.ReadLine()))
{
char[] commaEscape = new char[] {','};
char[] quoteEscape = new char[] {'"'};
string[] valueComponents = lineContents.Split(commaEscape);
//
// NOTE: In our sample, we assume that the order given to us is:
// objectclass,delta,anchor-attribute,name,email
//
//
// Check the objectclass node and see if this object class is
// something that we are interested in.
//
if (Nodes.ObjectClass == valueComponents[0].Trim(quoteEscape))
{
continue;
}
//
// This means that we are interested in this object class.
// Populate the the comma-delimited file.
//
m_xmlWriterExport.WriteStartElement(Nodes.Object);
m_xmlWriterExport.WriteElementString(
Nodes.ObjectClass,
valueComponents[0].Trim(quoteEscape)
);
m_xmlWriterExport.WriteElementString(
Nodes.Delta,
valueComponents[1].Trim(quoteEscape)
);
m_xmlWriterExport.WriteElementString(
Nodes.Anchor,
valueComponents[2].Trim(quoteEscape)
);
m_xmlWriterExport.WriteElementString(
Nodes.Name,
valueComponents[3].Trim(quoteEscape)
);
m_xmlWriterExport.WriteElementString(
Nodes.Email,
valueComponents[4].Trim(quoteEscape)
);
m_xmlWriterExport.WriteEndElement();
}
m_xmlWriterExport.WriteEndElement();
m_xmlWriterExport.Close();
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Target Platforms
Change History
See Also
Reference
IMAExtensible2FileExport Interface
IMAExtensible2FileExport Members
Microsoft.MetadirectoryServices Namespace