Share via


How to: Check for Necessary Attributes

During the provisioning step of Forefront Identity Manager Synchronization Service (FIM Synchronization Service), we recommend that you verify that on a FIM Synchronization Service database (metaverse) object, certain attribute values exist before you continue with the provisioning logic.

The following example shows how you can verify that an object has the required attribute and attribute values before provisioning logic creates new connectors. This specific example verifies that the employeeStatus attribute is present and contains either active or inactive.

If the employeeStatus attribute is not present or contains a value other than active or inactive, the example throws an UnexpectedDataException exception. The UnexpectedDataException exception causes the "extension-unexpected-attribute-value" error to appear in the Synchronization Service Manager for the management agent.

Public Sub Provision(ByVal mventry As MVEntry) Implements IMVSynchronization.Provision
    If (Not mventry("employeeStatus").IsPresent) Then
        Throw New UnexpectedDataException("employeeStatus is not present.")
    End If

    ' Employee Status can be either "active" or "inactive". Throw an 
    ' exception for a value other than active or inactive.

    Dim strEmployeeStatus As String
    strEmployeeStatus = mventry("employeeStatus").Value.ToLower
    Select Case (strEmployeeStatus)
        Case "active", "inactive"
            System.Diagnostics.Trace.WriteLine("Valid employeeStatus value: " + strEmployeeStatus)

        Case Else
            Throw New UnexpectedDataException("Invalid employeeStatus value: " + strEmployeeStatus)
    End Select
End Sub
void IMVSynchronization.Provision(MVEntry mventry)
{
    if(!mventry["employeeStatus"].IsPresent)
    {
        throw new UnexpectedDataException("employeeStatus not present.");
    }

    // Employee Status can be either "active" or "inactive". Throw an 
    // exception for a value other than active or inactive.

    string strEmployeeStatus = mventry["employeeStatus"].Value.ToLower();
    switch(strEmployeeStatus)
    {
        case "active":
        case "inactive":
            System.Diagnostics.Trace.WriteLine("Valid employeeStatus value: " + strEmployeeStatus);
            break;

        default:
            throw new UnexpectedDataException("Invalid employeeStatus value: " + strEmployeeStatus);
    }
}

See Also

Reference

UnexpectedDataException

Concepts

Creating and Checking Attribute Values