Last active
October 14, 2017 21:33
-
-
Save jkbryan/c98b59aae38587ab89aa84bb220b97f4 to your computer and use it in GitHub Desktop.
An Alternative To Using The Generic Array From File Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
Else | |
'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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub Initialize() Implements IMASynchronization.Initialize | |
Try | |
Dim config As XmlDocument = New XmlDocument() | |
config.Load("C:\FIMControl\rules-config.xml") | |
' | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<rules-extension-properties> | |
<mail-suffixes> | |
<values>blah.ac.uk,moo.ac.uk,meow.ac.uk,woof.ac.uk,squawk.ac.uk,hiss.ac.uk,neigh.ac.uk</values> | |
</mail-suffixes> | |
<ignore-email-address-errors> | |
<values>smartypants@woof.ac.uk</values> | |
</ignore-email-address-errors> | |
<ignore-functional-id-owner> | |
<values>random.person@someother.ac.uk</values> | |
</ignore-functional-id-owner> | |
</rules-extension-properties> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment