Step 9: Create a FIM metaverse rules extension
Applies To: Forefront Identity Manager
The test lab guide scenarios make use of a Forefront Identity Manager 2010 (FIM) metaverse rules extension dynamic-link library (DLL) that supplements the management agents that act as the primary interface between the connected data systems and the FIM metaverse. Synchronization Service Manager generates the necessary Visual Studio project files to create the DLL file, and you supply the program code that is compiled into the DLL. Sample code is provided for you in the following procedure.
To create a FIM metaverse rules extension
Log on to FIM1 as CORP\Administrator.
Click Start, click All Programs, click Microsoft Forefront Identity Manager, and then click Synchronization Service.
In Synchronization Service Manager, on the Tools menu, click Options.
In the Options dialog box, select the Enable metaverse rules extension and Enable Provitioning Rules Extension check boxes.
In Rules extension name, type
MVExtension.dll
, and then click Create Rules Extension Project.In the Create Extension Project dialog box, select the Launch in VS.NET IDE check box, and then click OK. Visual Studio 2012 will launch.
In the Review Project And Solution Changes dialog box, click OK. Internet Explorer will appear displaying information about the project conversion. Close Internet Explorer.
In Visual Studio, double-click MVExtension.vb.
On the EDIT menu, click Select All, and then on the EDIT menu, click Delete.
In the code window, type the following:
Imports System Imports System.Collections Imports Microsoft.MetadirectoryServices Public Class MVExtensionObject Implements IMVSynchronization Public Sub Initialize() Implements IMvSynchronization.Initialize ' TODO: Add initialization code here 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 Try If (mventry.ObjectType.Equals("person")) Then ProvisionToADUsers(mventry) If (mventry.ObjectType.Equals("person")) Then ProvisionToAMCUsers(mventry) If (mventry.ObjectType.Equals("user")) Then ProvisionToADUsers(mventry) If (mventry.ObjectType.Equals("organization")) Then ProvisionToAMCOrgunits(mventry) Catch ex As Exception Throw ex End Try 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 Private Sub ProvisionToADUsers(ByVal mventry As MVEntry) Try Dim numberofConnectors As Integer Dim myMA As ConnectedMA = mventry.ConnectedMAs("ADUsers") numberofConnectors = myMA.Connectors.Count If 0 = numberofConnectors Then Dim obCS As CSEntry obCS = myMA.Connectors.StartNewConnector("user") Dim DN As ReferenceValue Dim Container As String Container = "OU=FIMManaged," + My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\BHOLD\b1Core", "DomainName", Nothing).ToString() Dim RDN As String RDN = Nothing Try RDN = "CN=" + mventry("description").Value Catch erx As Exception End Try If Not RDN Is Nothing Then DN = myMA.EscapeDNComponent(RDN).Concat(Container) obCS.DN = DN obCS("sAMAccountName").Value = mventry("accountName").Value obCS("userAccountControl").IntegerValue = 66048 obCS("displayName").Value = mventry("description").Value obCS("unicodepwd").Values.Add("T3mpP@55") obCS.CommitNewConnector() End If End If Catch ex As Exception Throw ex End Try End Sub Private Sub ProvisionToAMCUsers(ByVal mventry As MVEntry) Try Dim numberofConnectors As Integer Dim myMA As ConnectedMA = mventry.ConnectedMAs("AMCUsers") numberofConnectors = myMA.Connectors.Count If 0 = numberofConnectors Then Dim obCS As CSEntry obCS = myMA.Connectors.StartNewConnector("user") Dim DN As ReferenceValue DN = myMA.EscapeDNComponent(System.Guid.NewGuid().ToString) obCS.DN = DN obCS.CommitNewConnector() End If Catch ex As Exception Throw ex End Try End Sub Private Sub ProvisionToAMCOrgunits(ByVal mventry As MVEntry) Try Dim numberofConnectors As Integer Dim myMA As ConnectedMA = mventry.ConnectedMAs("AMCOrgunits") numberofConnectors = myMA.Connectors.Count If 0 = numberofConnectors Then Dim obCS As CSEntry obCS = myMA.Connectors.StartNewConnector("OrganizationalUnit") Dim DN As ReferenceValue DN = myMA.EscapeDNComponent(System.Guid.NewGuid().ToString) obCS.DN = DN obCS.CommitNewConnector() End If Catch ex As Exception Throw ex End Try End Sub End Class
On the FILE menu, click Save MVExtension.vb.
On the BUILD menu, click Build MVExtension.
Close Visual Studio.
In the Synchronization Service Manager Options dialog box, click Browse and verify that MVExtension.dll appears in the list, and then click Cancel.
In the Options dialog box, click OK.
Close Synchronization Service Manager.
Next step
To continue building the BHOLD Access Management Connector test lab, see Step 10: Create FIM management agents.