Creating a Management Agent Rules Extension in C#
You can use C# to create a management agent rules extension. There are two ways to create the project files for rules extensions:
- Use Identity Manager to create a Visual Studio 2005 project.
- Use Visual Studio 2005 to create the project
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 (MIIS) 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 Lifecycle Manager 2007, Feature Pack 1 Help.
If you want to create your rules extension on a different system, you can use Visual Studio 2005 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 MIIS program folder. The default folder for ILM 2007 FP1 is C:\Program Files\Microsoft Identity Integration Server\bin\assemblies\.
To create a rules extension using Visual Studio 2005, you must complete the following steps in the order in which they appear:
- Create a new C# class library project
- Add a reference to the Microsoft.MetadirectoryServices assembly
- Copy the code to the code pane and make changes to the code
- Build the class library
- Install the rules extension in the rules extensions folder
To create a new C# class library project using Visual Studio 2005
Click Start, point to All Programs, and then click Microsoft Visual Studio 2005.
The Visual Studio 2005 development environment appears.
On the File menu, point to New, and then click Project.
In the New Project dialog box, in Project Types, click Visual C#.
On the Templates menu, click Class Library.
In the Name box, type the name of the rules extension that you are creating, and then click Browse.
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
On the Project menu in Visual Studio 2005, click Add Reference.
In the .NET tab of the Add Reference dialog box, 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 with the assembly file, click Microsoft.MetadirectoryServices.dll, and then click Open.
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
Delete the existing code in the code pane, and then copy the following code example to the code pane.
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> : IMASynchronization { public <extension object name>() { // // TODO: Add constructor logic here // } void IMASynchronization.Initialize () { // // TODO: write initialization code // } void IMASynchronization.Terminate () { // // TODO: write termination code // } bool IMASynchronization.ShouldProjectToMV (CSEntry csentry, out string MVObjectType) { // // TODO: Remove this throw statement if you implement this method // throw new EntryPointNotImplementedException(); } DeprovisionAction IMASynchronization.Deprovision (CSEntry csentry) { // // TODO: Remove this throw statement if you implement this method // throw new EntryPointNotImplementedException(); } bool IMASynchronization.FilterForDisconnection (CSEntry csentry) { // // TODO: write disconnection filter code // throw new EntryPointNotImplementedException(); } void IMASynchronization.MapAttributesForJoin (string FlowRuleName, CSEntry csentry, ref ValueCollection values) { // // TODO: write join mapping code // throw new EntryPointNotImplementedException(); } bool IMASynchronization.ResolveJoinSearch (string joinCriteriaName, CSEntry csentry, MVEntry[] rgmventry, out int imventry, ref string MVObjectType) { // // TODO: write join resolution code // throw new EntryPointNotImplementedException(); } void IMASynchronization.MapAttributesForImport( string FlowRuleName, CSEntry csentry, MVEntry mventry) { // // TODO: write your import attribute flow code // throw new EntryPointNotImplementedException(); } void IMASynchronization.MapAttributesForExport (string FlowRuleName, MVEntry mventry, CSEntry csentry) { // // TODO: write your export attribute flow code // throw new EntryPointNotImplementedException(); } } }
In the code, replace <sample namespace name> with the name of your project. Be sure to remove the angle brackets (< >).
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
On the Build menu, click Build Solution.
If you see the following message, the rules extension was successfully built:
------ 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 using the rules extension, install it in the Microsoft Identity Integration Server rules extensions folder. The default folder for rules extensions is C:\Program Files\Microsoft Identity Integration Server\Extensions.
This procedure is optional. Alternatively, you can set Visual Studio 2005 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
In Solution Explorer, click your class library project.
On the View menu, click Property Pages.
Select the Compile tab.
In the Configuration drop-down list box, click All Configurations.
In Build Output Path textbox, 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.
Close the Property Pages dialog box.
Keep the following issues in mind when you use the Extensions folder:
- Avoid using the Extensions folder to store files that must be kept open or frequently modified, such as log files. The Extensions folder is automatically backed up to the SQL Server 2000 database. If any file in this folder is locked, the backup to the SQL Server 2000 database fails.
- Avoid making changes to any files in the Extensions folder while running a management agent run profile. If you change a file in the Extensions folder while running a management agent run profile, the action will return the "stopped-extension-dll-updated-version" value.
- Store configuration information required by your rules extension in an initialization file in the Extensions folder, because the Extensions folder is backed up by the SQL Server database. For more information, see Example:_Reading_Settings_for_Rules_Extensions.
Send comments about this topic to Microsoft
Build date: 2/16/2009