Imports Microsoft.MetadirectoryServices Public Class MAExtensionObject 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 connector filter 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 ' Variables and constant Dim employeeEndDate As Date Const ADS_UF_NORMAL_ACCOUNT As Integer = &H200 'Normal AD account Const ADS_UF_ACCOUNTDISABLE As Integer = &H2 'Disable AD account Const ADS_UF_PASSWD_NOTREQD As Integer = &H20 ' Password not required Dim currentValue As Long Dim ADMAName As String = "AD" ' Apply this rule only for User object Select Case FlowRuleName Case "Title" csentry("Title").Value = mventry("Title").Value.ToString.ToUpper() Case "userAccountControl" ' Retrieve employeeEndDate (could be empty) ' If empty end date, initialize at 2999/12/31 If mventry("employeeEndDate").IsPresent _ AndAlso Not String.IsNullOrEmpty(mventry("employeeEndDate").Value) Then employeeEndDate = DateTime.ParseExact(mventry("employeeEndDate").Value, "yyyyMMddHHmmss.0Z", System.Globalization.CultureInfo.InvariantCulture) Else employeeEndDate = DateTime.ParseExact("29991231235959.0Z", "yyyyMMddHHmmss.0Z", System.Globalization.CultureInfo.InvariantCulture) End If If csentry("useraccountcontrol").IsPresent Then currentValue = csentry("useraccountcontrol").IntegerValue Else currentValue = ADS_UF_NORMAL_ACCOUNT End If ' Disabled or enabled AD user account based on EmployeeEndDate If Date.Compare(employeeEndDate, Date.UtcNow) > 0 Then csentry("useraccountcontrol").IntegerValue = (currentValue Or ADS_UF_NORMAL_ACCOUNT) _ And (Not ADS_UF_ACCOUNTDISABLE) Else csentry("useraccountcontrol").IntegerValue = currentValue _ Or ADS_UF_ACCOUNTDISABLE _ Or ADS_UF_PASSWD_NOTREQD End If End Select 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