Imports System.Xml Public Class MVExtensionObject Implements IMVSynchronization ' ' These two variables are initialized based on a xml configuration file ' The values are read during the Initialize() method of the Rules Extension ' Dim MIMUsersContainer As String ' ' Number of retries on name conflict ' Private Const RETRY_NUM_LIMIT = 1000 Public Sub Initialize() Implements IMvSynchronization.Initialize Const SCENARIO_XML_CONFIG = "\simpleprov.xml" Dim config As XmlDocument = New XmlDocument Dim dir As String = Utils.ExtensionsDirectory() config.Load(dir + SCENARIO_XML_CONFIG) Dim rnode As XmlNode = config.SelectSingleNode("rules-extension-properties/account-provisioning/container") Dim node As XmlNode = rnode.SelectSingleNode("root") Dim rootContainer As String = node.InnerText MIMUsersContainer = rootContainer End Sub Public Sub Terminate() Implements IMvSynchronization.Terminate ' TODO: Add termination code here End Sub Public Sub Provision(ByVal mventry As MVEntry) Implements IMVSynchronization.Provision Dim FootwearADMA As ConnectedMA Dim dn As ReferenceValue Dim container As String Dim rdn As String Dim myConnector As CSEntry Dim csentry As CSEntry Dim numADConnectors As Integer Dim successful As Boolean = False Dim cnForObject As String Dim numberToAppend As Integer = 1 If Not mventry.ObjectType.Equals("person") Then Exit Sub End If If Not mventry("cn").IsPresent Then Throw New UnexpectedDataException("cn does not exist on MV object") End If FootwearADMA = mventry.ConnectedMAs("ADFootwear") ' ' Get the cn attribute from MV which will be used to configure CS dn ' cnForObject = mventry("cn").Value.ToString() container = MIMUsersContainer Do Try ' Based on the value of "cn" determine the RDN in AD rdn = "CN=" & cnForObject ' Now construct the DN based on RDN and Container dn = FootwearADMA.EscapeDNComponent(rdn).Concat(container) ' ' If there is no connector present, add a new AD connector ' and call a subroutine to set the initial values on the CS Object ' numADConnectors = FootwearADMA.Connectors.Count() If 0 = numADConnectors Then csentry = FootwearADMA.Connectors.StartNewConnector("user") csentry.DN = dn SetInitialValues(csentry, mventry) csentry.CommitNewConnector() csentry("userAccountControl").Values.Add("512") ElseIf 1 = numADConnectors Then ' ' check if the connector has a different DN and rename if necessary ' First get the connector ' myConnector = FootwearADMA.Connectors.ByIndex(0) ' ' MMS will rename/move if different, if not nothing will happen ' myConnector.DN = dn Else Throw New UnexpectedDataException("multiple AD connectors:" + numADConnectors.ToString) End If successful = True Catch ex As ObjectAlreadyExistsException ' ' There is a duplicate object in the target AD, ' change the cn accordingly to avoid confict ' cnForObject = mventry("cn").Value & " (" _ & numberToAppend.ToString & ")" numberToAppend = numberToAppend + 1 If numberToAppend > RETRY_NUM_LIMIT Then Throw New UnexpectedDataException( _ "Retry for " & mventry("cn").Value _ & " exceeds limit " & numberToAppend.ToString) End If Finally ' Add cleanup code in the Finally section End Try Loop While Not successful End Sub ' Set Values on a NEW provisioned CS Entry Private Sub SetInitialValues( _ ByRef csentry As CSEntry, _ ByVal mventry As MVEntry) csentry("unicodepwd").Values.Add("P@ssw0rd") End Sub Public Function ShouldDeleteFromMV(ByVal csentry As CSEntry, ByVal mventry As MVEntry) As Boolean Implements IMVSynchronization.ShouldDeleteFromMV ' TODO: Add MV deletion code here Throw New EntryPointNotImplementedException() End Function End Class ##################################################### Here a simpleprov OU=MIM,DC=Footwear,DC=com