Partager via


How to: Create Management Agent Rules Extensions

A management agent rules extension must implement the IMASynchronization interface. The contents of IMASynchronization are specified in the Microsoft.MetadirectoryServices namespace and include the following methods:

Creating a Management Agent Rules Extension Project

There are two ways to create a rules extension in a Microsoft Visual Studio 2008 project. In either case, use a unique name for each source code file that you use to create your rules extensions. It is much easier to search for the line of code that is causing an error if you use unique file names.

The following examples show a class declaration for a management agent rules extension:

Public Class Sample_Visual_Basic_MA_Extension
    Implements IMASynchronization
namespace Sample_CSharp_MA_Extension
{
    public class MyMAExtensionClass : IMASynchronization
    {
    }
}

When you implement an interface, you must implement all the methods that are defined by that interface. This means that when you create a management agent rules extension, you must also implement, at a minimum, all methods that are listed earlier in this topic.

The following example shows an entire class declaration for a management agent rules extension:

Public Class Sample_Visual_Basic_MA_Extension
    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
public class MAExtensionObject : IMASynchronization
{
public MAExtensionObject()
{
            //
            // 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();
        }
}

See Also

Reference

IMASynchronization

Concepts

Creating Rules Extensions