Microsoft Identity Integration Server 2003 Developer Reference

Creating a Management Agent Rules Extension in Visual Basic .NET

You can use Visual Basic .NET to create a management agent rules extension. There are two ways to create the project files for rules extensions:

Using Identity Manager is the easiest way to create the project. The Identity Manager creates the necessary files and automatically makes the reference to the Microsoft.MetadirectoryServices assembly. However, using the Identity Manager to create your project files limits you to creating your rules extension on the same system where Microsoft Identity Integration Server 2003 is installed. For more information about using Identity Manager to create the project files, see "Create a rules extension for a management agent" in Microsoft Identity Integration Server 2003 Help.

If you want to create your rules extension on a different system, you can use Visual Studio .NET 2003 to create the project files. You will need to copy the Microsoft.MetadirectoryServices assembly to your development system and manually create a reference to the assembly. You can find the assembly in the bin\assemblies folder of the Microsoft Identity Integration Server program folder. The default folder for Microsoft Identity Integration Server is C:\Program Files\Microsoft Identity Integration Server\bin\assemblies\.

To create a rules extension using Visual Studio .NET, you must complete the following steps:

  1. Create a new Visual Basic class library project
  2. Add a reference to the Microsoft.MetadirectoryServices assembly
  3. Copy the code to the code pane and make changes to the code
  4. Build the class library
  5. Install the rules extension in the rules extensions folder (Optional)

To create a new Visual Basic .NET class library project using Visual Studio .NET 2003

  1. Click Start, point to All Programs, and then click Visual Studio .NET 2003.

    The Microsoft Visual Studio .NET 2003 development environment appears.

  2. On the File menu, point to New, and then click Project.
  3. In the New Project dialog box, in Project Types, click Visual Basic Projects.
  4. On the Template menu, click Class Library.
  5. In the Name box, type the name of your rules extension, and then click Browse.
  6. Browse to the location where you want to store the project files, click Open, and then click OK.

    Your project name now appears in Solution Explorer.

Note  We recommend that you store the project on your local computer rather than at a network location.

To add a reference to the Microsoft.MetadirectoryServices assembly

  1. On the Project menu in Visual Studio .NET 2003, click Add Reference.
  2. In the .NET tab of the Add Reference dialog box, click Microsoft.MetadirectoryServices, and then click Select. If the file does not appear in the Selected Components list, click Browse. In the Selected Components dialog box, go to the folder with the assembly file, click Microsoft.MetadirectoryServices.dll, and then click Open.

    Verify that Microsoft.MetadirectoryServices.dll appears in the Selected Components list of the Add Reference dialog box.

  3. Click OK to close the Add Reference dialog box.

    In Solution Explorer, Microsoft.MetadirectoryServices now appears as one of the references.

To copy the code to the code pane and make changes to the code

  1. Delete the existing code in the code pane, and then copy the following example to the code pane.
    Imports Microsoft.MetadirectoryServices
    
    ' Replace <sample extension object name> with the name of your rules 
    ' extension class. If you do not replace <sample extension object name> 
    ' with the name of your rules extension class, you will not be able to
    ' compile this file.
    
    Public Class <sample extension object name>
    	Implements IMASynchronization
    
    	Public Sub Initialize() Implements IMASynchronization.Initialize
    		' TODO: Add initialization code here
    	End Sub
    
    	Public Sub Terminate() Implements IMASynchronization.Terminate
    		' TODO: Add termination code here
    	End Sub
    
    	Public Function ShouldProjectToMV(ByVal csentry As CSEntry, ByRef MVObjectType As String) As Boolean Implements IMASynchronization.ShouldProjectToMV
    		' TODO: Remove this throw statement if you implement this method
    		Throw New EntryPointNotImplementedException()
    	End Function
    
    	Public Function FilterForDisconnection(ByVal csentry As CSEntry) As Boolean Implements IMASynchronization.FilterForDisconnection
    		' TODO: Add stay-disconnector code here
    		Throw New EntryPointNotImplementedException()
    	End Function
    
    	Public Sub MapAttributesForJoin(ByVal FlowRuleName As String, ByVal csentry As CSEntry, ByRef values As ValueCollection) Implements IMASynchronization.MapAttributesForJoin
    		' TODO: Add join mapping code here
    		Throw New EntryPointNotImplementedException()
    	End Sub
    
    	Public Function ResolveJoinSearch(ByVal joinCriteriaName As String, ByVal csentry As CSEntry, ByVal rgmventry() As MVEntry, ByRef imventry As Integer, ByRef MVObjectType As String) As Boolean Implements IMASynchronization.ResolveJoinSearch
    		' TODO: Add join resolution code here
    		Throw New EntryPointNotImplementedException()
    	End Function
    
    	Public Sub MapAttributesForImport(ByVal FlowRuleName As String, ByVal csentry As CSEntry, ByVal mventry As MVEntry) Implements IMASynchronization.MapAttributesForImport
    		' TODO: write your import attribute flow code
    				Throw New EntryPointNotImplementedException()
    	End Sub
    
    	Public Sub MapAttributesForExport(ByVal FlowRuleName As String, ByVal mventry As MVEntry, ByVal csentry As CSEntry) Implements IMASynchronization.MapAttributesForExport
    		' TODO: Add export attribute flow code here
    		Throw New EntryPointNotImplementedException()
    	End Sub
    
    	Public Function Deprovision(ByVal csentry As CSEntry) As DeprovisionAction Implements IMASynchronization.Deprovision
    		' TODO: Remove this throw statement if you implement this method
    		Throw New EntryPointNotImplementedException()
    	End Function
    End Class
    
  2. In the code, replace all instances of <sample extension object name> with the name of your rules extension class. Be sure to remove the angle brackets (< >).

To build the class library

This procedure is optional. Alternatively, you can set Visual Studio .NET 2003 to install the rules extension automatically in the rules extensions folder as part of the build process.

To install the rules extension in the rules extensions folder

  1. In Solution Explorer, click your class library project.
  2. On the View menu, click Property Pages.

    There are two folders in the Property Pages dialog box: Common Properties and Configuration Properties.

  3. Open the Configuration Properties folder. In the Configuration drop-down list box, click All Configurations.
  4. In the left pane of the Property Pages dialog box, click Build.
  5. In Output Path, type the name of the rules extensions folder or browse to the location of the rules extensions folder.

    The default folder for rules extensions is C:\Program Files\Microsoft Identity Integration Server\Extensions.

  6. Click OK to close the Property Pages dialog box.
Keep the following issues in mind when you use the Extensions folder: