Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
An Alternative To Using The Generic Array From File Function
Imports Microsoft.MetadirectoryServices
Imports System
Imports System.directoryservices
Imports ActiveDs
Imports System.Globalization
Imports Microsoft.MetadirectoryServices.Logging
Imports System.IO
Imports System.Xml
Public Class MAExtensionObject_MYADMA
Implements IMASynchronization
'Date & Logginglevel variables for logging files:
Dim dtDateNowHour As Integer = Date.Now.Hour
Dim dtDateNowDay As Integer = Date.Now.Day
Dim dtDateNowMonth As Integer = Date.Now.Month
Dim dtDateNowYear As Integer = Date.Now.Year
Dim loggingLevel As Integer = 0
Dim ValidMailSuffixes As String
Dim IgnoreFunctionalIDOwner As String
Dim IgnoreEmailAddressErrors As String
Case "emailAddressPresent-ADMA-Import"
'AD attributes required: mail and msExchHomeServerName
' Default setting = False
mventry("emailAddressPresent").Value = "False"
If csentry("mail").IsPresent And csentry("msExchHomeServerName").IsPresent Then
Dim suffix() As String = Split((csentry("mail").Value), "@")
If ValidMailSuffixes.Contains(suffix(1).ToLower) Then
mventry("emailAddressPresent").Value = "True"
'If a suffix from the above is not found - raise an error, so that the suffix can be added to the text file or simply sorted out - where a mistake was made.
Throw New Exception("Invalid email suffix found: " & suffix(1))
End If
ElseIf csentry("mail").IsPresent And csentry("mailNickName").IsPresent Then
'This person is a mail enabled user, maybe with an island site email address or just something else, so we want them to be able to be added to distribution lists....
mventry("emailAddressPresent").Value = "True"
End If
Public Sub Initialize() Implements IMASynchronization.Initialize
Dim config As XmlDocument = New XmlDocument()
Dim suffixesnode As XmlNode = config.SelectSingleNode("rules-extension-properties/mail-suffixes")
Dim suffixvaluenode As XmlNode = suffixesnode.SelectSingleNode("values")
Dim suffixesvalue As String = suffixvaluenode.InnerText
ValidMailSuffixes = suffixvaluenode.InnerText
Dim ieaenode As XmlNode = config.SelectSingleNode("rules-extension-properties/ignore-email-address-errors")
Dim ieeavaluenode As XmlNode = ieaenode.SelectSingleNode("values")
Dim ieaevalue As String = ieeavaluenode.InnerText
IgnoreEmailAddressErrors = ieeavaluenode.InnerText
Dim ifionode As XmlNode = config.SelectSingleNode("rules-extension-properties/ignore-functional-id-owner")
Dim ifiovaluenode As XmlNode = ifionode.SelectSingleNode("values")
Dim ifiovalue As String = ifionode.InnerText
IgnoreFunctionalIDOwner = ifiovaluenode.InnerText
Catch nre As NullReferenceException
'If a tag does not exist in the xml, then the stopped-extension-dll error will be thrown.
Throw nre
Catch e As Exception
Throw e
End Try
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment