Provisioning Code (Extension DLL)
'Updated February 23, 2005
'Steve Bryant
Imports Microsoft.MetadirectoryServices
'Imports Mms_Metaverse.MVExtensionObject
Public Class MVExtensionObject
Implements IMVSynchronization
Implements IMASynchronization
Public Sub Initialize() Implements
IMVSynchronization.Initialize
' TODO: Add initialization code here
End Sub
Public Sub Terminate() Implements IMVSynchronization.Terminate
' TODO: Add termination code here
End Sub
Public Sub Provision(ByVal mventry As MVEntry) Implements
IMVSynchronization.Provision
Dim BusinessUnit1 As ConnectedMA ' Management agent object
Dim Legacy55 As ConnectedMA ' Management agent object
Dim Connectors As Integer ' Management agent
connectors
Dim DN As ReferenceValue ' Distinguished name
attribute
Dim Container As String ' Container name
Dim RDN As String ' Relative
distinguished name strings
Dim csentry As CSEntry ' Connector space entry
object
Dim SMTPAddress As String ' Building the SMTP
target address
Dim TargetAddress As String ' Building the SMTP
target address
Dim displayname As String ' Identify the display
name
Dim textEncodedORAddress As String
Dim mailnickname As String
If mventry.ObjectType = "locality" Then Exit Sub
Legacy55 = mventry.ConnectedMAs("Exchange 55 GAL MA")
BusinessUnit1 = mventry.ConnectedMAs("Business Unit MA")
'BusinessUnit2 = mventry.connectedMAs("Second Business Unit
MA)
'Begin code for First Business Unit AD
If BusinessUnit1.Connectors.Count = 0 Then
BusinessUnit1 = mventry.ConnectedMAs("Business Unit
MA")
Connectors = BusinessUnit1.Connectors.Count
' Insert the OU for the business Unit here
mailnickname = mventry("mailNickname").Value
displayname = mventry("DisplayName").Value
SMTPAddress = mventry("mail").Value
TargetAddress = mventry("mail").Value
Container = "OU=MIIS Import,DC=AlpineSkiHouse,DC=com"
RDN = "CN=" & mventry("cn").Value
DN =
BusinessUnit1.EscapeDNComponent(RDN).Concat(Container)
' This line below denotes the target object class. We
are using custom recipients only
'csentry =
BusinessUnit1.Connectors.StartNewConnector("contact")
csentry =
ExchangeUtils.CreateMailEnabledContact(BusinessUnit1, DN, mailnickname,
TargetAddress)
csentry.DN = DN
csentry.CommitNewConnector()
End If
'Begin code for First Business Unit AD
'Begin code for Legacy Exchange 5.5 Org
If Legacy55.Connectors.Count = 0 Then
'Provisioning based upon metaverse object type person
If "Metaverse_Contact" = mventry.ObjectType Then
Legacy55 = mventry.ConnectedMAs("Exchange 55 GAL
MA")
mailnickname = mventry("mailNickname").Value
displayname = mventry("DisplayName").Value
SMTPAddress = mventry("mail").Value
' Construct the textEncodedORAddress if needed
textEncodedORAddress =
mventry("TextEncodedORAddress").Value
' If there is a g= missing in the
TextEncodedORAddress, then rem out the line above and allow these to
execute
'Dim strvar1 As String
'strvar1 = mventry("TextEncodedORAddress").Value
'textEncodedORAddress =
(StrReverse(Left(StrReverse(strvar1), InStr(2, StrReverse(strvar1), ";")
- 1) & "=g;" & Right(StrReverse(strvar1), (Len(StrReverse(strvar1)) -
InStr(2, StrReverse(strvar1), ";")))))
' Construct the distinguished name
DN = Legacy55.EscapeDNComponent("CN=" +
mventry("uid").Value).Concat("cn=import,ou=Atlanta,o=Exchange55")
csentry =
ExchangeUtils.Create55CustomRecipient(Legacy55, DN, mailnickname,
displayname, SMTPAddress, textEncodedORAddress)
End If
End If
'End code for Legacy Exchange 5.5 Org
End Sub
Public Function FilterForDisconnection(ByVal csentry As
Microsoft.MetadirectoryServices.CSEntry) As Boolean Implements
Microsoft.MetadirectoryServices.IMASynchronization.FilterForDisconnection
End Function
Public Sub MapAttributesForExport(ByVal FlowRuleName As String,
ByVal mventry As MVEntry, ByVal csentry As CSEntry) Implements
IMASynchronization.MapAttributesForExport
Select Case FlowRuleName.ToLower
Case "cd.remote-address:textencodedoraddress<-mv.metaverse_contact:textencodedoraddress"
Dim strvar1 As String =
mventry("TextEncodedORAddress").Value
csentry("TextEncodedORAddress").Value =
(StrReverse(Left(StrReverse(strvar1), InStr(2, StrReverse(strvar1), ";")
- 1) & "=g;" & Right(StrReverse(strvar1), (Len(StrReverse(strvar1)) -
InStr(2, StrReverse(strvar1), ";")))))
Case "cd.contact:c<-mv.metaverse_contact:c"
csentry("c").Value = Left(mventry("c").Value, 2)
Case "proxyaddresses"
If mventry("proxyAddresses").IsPresent Then
Dim entry As Value
Dim work As String
Dim zapSMTP As New System.collections.ArrayList
' discover existing csentry SMTP and smtp keys
for removal
If csentry("proxyAddresses").IsPresent Then
For Each entry In
csentry("proxyAddresses").Values
work = Left(entry.ToString, 4)
Select Case work
Case "SMTP", "smtp"
zapSMTP.Add(entry.ToString)
End Select
Next
End If
'remove existing SMTP and smtp keys discovered
above
For Each work In zapSMTP
csentry("proxyAddresses").Values.Remove(work)
Next
'add mventry SMTP,smtp and X500 keys to
connected system
For Each entry In
mventry("proxyAddresses").Values
work = Left(entry.ToString, 4)
Select Case work
Case "SMTP", "X500", "smtp"
csentry("proxyAddresses").Values.Add(entry.ToString)
End Select
Next
End If
Case "msexchpoliciesexcluded"
' Add this bit in there somewhere to identify the
target folder
' We would need similar code to identify the
Exchange 5.5 system
'Const PROVISIONED_OU = "ou=mms,dc=testeurope,dc=testfs,dc=fujitsu,dc=local"
'If
csentry.DN.ToString.ToLower.EndsWith(PROVISIONED_OU) Then
csentry("msExchPoliciesExcluded").Value =
"{26491CFC-9E50-4857-861B-0CB8DF22B5D7}"
'End If
End Select
End Sub
Public Sub MapAttributesForImport(ByVal FlowRuleName As String,
ByVal csentry As Microsoft.MetadirectoryServices.CSEntry, ByVal mventry
As Microsoft.MetadirectoryServices.MVEntry) Implements
Microsoft.MetadirectoryServices.IMASynchronization.MapAttributesForImport
Select Case FlowRuleName.ToLower
Case "cd.organizationalperson:co->mv.metaverse_contact:c"
If csentry("co").IsPresent Then
mventry("c").Value = Left(csentry("co").Value,
2)
End If
Case "mail", "rfc822mailbox"
fixString(csentry, FlowRuleName, mventry,
FlowRuleName)
Case "mailnickname"
fixString(csentry, "RDN", mventry, FlowRuleName)
Case "uid"
fixString(csentry, FlowRuleName, mventry,
FlowRuleName)
Case "cd.remote-address:target-address->mv.metaverse_contact:targetaddress"
If csentry("target-address").IsPresent Then
mventry("targetaddress").Value =
Mid(csentry("target-address").Value, 6)
End If
Case "adtargetaddress"
fixString(csentry, "mail", mventry, "targetaddress",
"SMTP:")
Case "targetaddress"
fixString(csentry, "rfc822mailbox", mventry,
FlowRuleName, "SMTP:")
Case "proxyaddresses"
Dim tempVal As Object
If csentry("otherMailbox").IsPresent Then
For Each tempVal In
csentry("otherMailbox").Values
mventry("proxyAddresses").Values.Add(tempVal.ToString)
Next
End If
If csentry("rfc822mailbox").IsPresent Then
mventry("proxyAddresses").Values.Add("SMTP:" &
csentry("rfc822mailbox").Value)
End If
If csentry("textEncodedORAddress").IsPresent Then
mventry("proxyAddresses").Values.Add("X400:" &
csentry("textEncodedORAddress").Value)
End If
End Select
End Sub
Public Sub MapAttributesForJoin(ByVal FlowRuleName As String,
ByVal csentry As Microsoft.MetadirectoryServices.CSEntry, ByRef values
As Microsoft.MetadirectoryServices.ValueCollection) Implements
Microsoft.MetadirectoryServices.IMASynchronization.MapAttributesForJoin
End Sub
Public Function ResolveJoinSearch(ByVal joinCriteriaName As
String, ByVal csentry As Microsoft.MetadirectoryServices.CSEntry, ByVal
rgmventry() As Microsoft.MetadirectoryServices.MVEntry, ByRef imventry
As Integer, ByRef MVObjectType As String) As Boolean Implements
Microsoft.MetadirectoryServices.IMASynchronization.ResolveJoinSearch
End Function
Public Function ShouldProjectToMV(ByVal csentry As
Microsoft.MetadirectoryServices.CSEntry, ByRef MVObjectType As String)
As Boolean Implements
Microsoft.MetadirectoryServices.IMASynchronization.ShouldProjectToMV
End Function
Public Sub Terminate1() Implements
Microsoft.MetadirectoryServices.IMASynchronization.Terminate
End Sub
Public Function ShouldDeleteFromMV(ByVal csentry As
Microsoft.MetadirectoryServices.CSEntry, ByVal mventry As
Microsoft.MetadirectoryServices.MVEntry) As Boolean Implements
Microsoft.MetadirectoryServices.IMVSynchronization.ShouldDeleteFromMV
End Function
Public Function Deprovision(ByVal csentry As
Microsoft.MetadirectoryServices.CSEntry) As
Microsoft.MetadirectoryServices.DeprovisionAction Implements
Microsoft.MetadirectoryServices.IMASynchronization.Deprovision
End Function
Public Sub Initialize1() Implements
Microsoft.MetadirectoryServices.IMASynchronization.Initialize
End Sub
Private Sub fixString(ByVal csentry As CSEntry, ByVal
csAttrName As String, ByVal mventry As MVEntry, ByVal mvAttrName As
String, Optional ByVal preFix As String = "")
' takes the csentry csAttrName and removes illegal
characters
' and prepends prefix if provided e.g. SMTP:
If csentry(csAttrName).IsPresent Then
Dim work As String = csentry(csAttrName).Value
work = Replace(work, "/", "")
work = Replace(work, "\", "")
work = Replace(work, "?", "")
mventry(mvAttrName).Value = preFix & work
End If
End Sub
End Class
|