MIM 2016: Read from xml config file using VB.NET

Here is what I want to do

  1. I am reading users from different ADs into my MIM 2016. I am also exporting the users to different Ads.
  2. I have some environmental variables that I would like to set based on the source object.
  3. I do not want to put these variables in my VB code. There should be flexibility so that the Admin can add new information or change existing ones.
  4. I want to search in the xml config for some identifier of the user and then read the variables I want.
  5. I want the Admin to be able to specify which Management agent not to provision to.

The xml config file

<DocumentElement>

<Table1>

<DestinationMA>TLK1 GAL MA</DestinationMA>

<OriginatingForest>tlk1.com</OriginatingForest>

<OUMapping> OU=TLK1Users,DC=tlkenterprise1,DC=net</OUMapping>

<Ldap>LDAP://DC=tlkenterprise1,DC=net </Ldap>

</Table1>

<Table1>

<DestinationMA>TLK2 GAL MA</DestinationMA>

<OriginatingForest>tlk2.com</OriginatingForest>

<OUMapping> OU=TLK2Users,DC=tlkenterprise1,DC=net</OUMapping>

<Ldap>LDAP://DC=tlkenterprise2,DC=net </Ldap>

</Table1>

<Table2>

<DoNotProvision>TLK3 GALSync MA</DoNotProvision>

</Table2>

</DocumentElement>

The code

  1. Dim OUDataSet As New DataSet  
  2. ‘Get the OU config data   
  3. Dim dir As String = Utils.ExtensionsDirectory  
  4. OUDataSet.ReadXml(dir + “\tlkconfig.xml”)  
  5. Dim adminGroup As String = Nothing  
  6.             Dim okayToProvision As Boolean = False  
  7.             Dim ProvCollection As Array = Nothing  
  8.             Dim adminCollection As Array = Nothing  
  9.        Dim MA As ConnectedMA  
  10.   Dim myOriginatingForest As String = mventry(“msExchOriginatingForest”).Value.ToLower()  
  11.             Dim myOrganizationalUnit As String = Nothing  
  12.  
  13. ‘We want to prevent any contacts or persons from being provisioned based on xml config info  
  14.             ‘Get the restricted Prov MA from the Xml file  
  15.             ProvCollection = OUDataSet.Tables(“Table2”).Select(“DoNotProvision='” + MA.Name + “‘”)  
  16.  
  17.             ‘Check to see if there is a matching MA in the xml file  
  18.             If ProvCollection.Length <> 0 Then  
  19.                 Exit Sub  
  20.             End If  
  21.  
  22. ‘Get the DN from the xml config  
  23. adminCollection = OUDataSet.Tables(“Table1”).Select(“DestinationMA='” + MA.Name + “‘ 
  24. and “ + “OriginatingForest='” + myOriginatingForest + “‘”)  
  25.    ‘Check to see if there is a matching forest in the xml file  
  26.   If adminCollection.Length = 0 Then  
  27.     Throw New ArgumentException(“No value returned in xml file when 
  28. finding originating forest in mapping file = “ + myOriginatingForest + ” “ + MA.Name)  
  29.       End If  
  30.   If adminCollection.Length <> 0 Then  
  31.  For Each item As DataRow In adminCollection  
  32.           ‘Set the DN value  
  33.    myOrganizationalUnit = item(“OUMapping”).ToString()  
  34.      Next  
  35.   End If