You can use the C# programming language to create a Forefront Identity Manager Synchronization Service (FIM Synchronization Service) database (metaverse) rules extension for FIM Synchronization Service. There are two ways to create the project files for rules extensions:

Using Synchronization Service Manager is the easiest way to create the project. The Synchronization Service Manager creates the necessary files and automatically makes the reference to the Microsoft.MetadirectoryServices.dll assembly. However, using the Synchronization Service Manager to create your project files limits you to creating your rules extension on the same system where FIM Synchronization Service is installed. For more information about using Synchronization Service Manager to create the project files, see the Forefront Identity Manager Technical Reference.

If you want to create your rules extension on a different system, you can use Visual Studio 2008 to create the project files. You must copy the Microsoft.MetadirectoryServices.dll 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 FIM Synchronization Service program folder. The default folder for FIM Synchronization Service is %ProgramFiles%\Microsoft Forefront Identity Manager\2010\Synchronization Service\bin\assemblies\.

To create the rules extension using Visual Studio 2008, you must follow these steps in the order in which they appear:

To create a new C# class library project using Visual Studio 2008

  1. Click Start, point to All Programs, and then click Microsoft Visual Studio 2008.

    The Visual Studio 2008 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 C#.

  4. On the Templates menu, click Class Library.

  5. In the Name box, type the name of the rules extension that you are creating, and then click Browse.

  6. Browse to the location where you want to store the project files, click Open, and then click OK. The name of the new project now appears in Solution Explorer.

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

To add a reference to the Microsoft.MetadirectoryServices assembly

  1. In Visual Studio 2008, on the Project menu, click Add Reference.

  2. In the Add Reference dialog box, on the .NET tab, click Microsoft.MetadirectoryServices, and then click OK. If the file does not appear in the Component Name list, click the Browse tab. Browse to the folder that contains the assembly file, click Microsoft.MetadirectoryServices, and then click Open.

  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 and paste the following code example to the code pane.

    C#  Copy Code
    using System;
    using Microsoft.MetadirectoryServices;
    
    // Replace <sample namespace name>  with the name of your rules extension.
    // If you do not replace <sample namespace name> with the name of your
    // rules extension, you will not be able to compile this file.
    
    namespace <sample namespace name>
    {
    	// Replace <extension object name> with the name of your rules 
    	// extension class. If you do not replace <extension object name>
    	// with the name of your rules extension class, you will not be 
    	// able to compile this file.
    
    	/// <summary>
    	/// Summary description for <extension object name>.
    	/// </summary>
    	public class <extension object name> : IMVSynchronization
    	{
    		public <extension object name>()
    		{
    			//
    			// TODO: Add constructor logic here.
    			//
    	}
    
    		void IMVSynchronization.Initialize ()
    		{
    			//
    			// TODO: Add initialization logic here.
    			//
    	}
    
    		void IMVSynchronization.Terminate ()
    		{
    			//
    			// TODO: Add termination logic here.
    			//
    	}
    
    		void IMVSynchronization.Provision (MVEntry mventry)
    		{
    			//
    			// TODO: Remove this throw statement if you implement this method.
    			//
    			throw new EntryPointNotImplementedException();
    	}
    
    		bool IMVSynchronization.ShouldDeleteFromMV (CSEntry csentry, MVEntry mventry)
    		{
    			//
    			// TODO: Add MV deletion logic here.
    			//
    			throw new EntryPointNotImplementedException();
    	}
    }
    }
    
  2. In the code, replace <sample namespace name> with the name of your project. Be sure to remove the angle brackets (< >).

  3. 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

  1. On the Build menu, click Build Solution.

    If the following message appears, the rules extension was successfully built:

      Copy Code
    ------ Build started: Project: Management Agent Rules Extension, Configuration: Debug .NET ------
    
    Preparing resources...
    Updating references...
    Performing main compilation...
    Building satellite assemblies...
    
    
    
    ---------------------- Done ----------------------
    
    	Build: 1 succeeded, 0 failed, 0 skipped
    

    The rules extension file, which has a .dll extension, is in the bin\Debug folder of your project folder.

    Before you use the rules extension, install it in the FIM Synchronization Service rules extensions folder. The default folder for rules extensions is %ProgramFiles%\Microsoft Forefront Identity Manager\2010\Synchronization Service\Extensions.

The following procedure is optional. You can set Visual Studio 2008 to install the rules extension automatically in the 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, click All Configurations.

  4. In the left pane of the Property Pages dialog box, click Build.

  5. In the Output Path box, 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 %ProgramFiles%\Microsoft Forefront Identity Manager\2010\Synchronization Service\Extensions.

See Also