Solved

Validate SMTP address in Exchange2003/AD

Posted on 2007-03-30
5
347 Views
Last Modified: 2008-05-31
We are creating user accounts/mailboxes in AD 2003/Exchange 2003 with ADSI-scripting (VB-script). We also want to set an SMTP address during/after creation and NOT use RUS to automatically set an address. Is there a way to validate an SMTP address before setting it? I know we can loop "ProxyAddresses", but it feels time- and resource consuming. When using for instance "Active Directory Users and Copmputers" to set an SMTP address, a validation is done...
0
Comment
Question by:itsupportoll
  • 2
5 Comments
 
LVL 70

Expert Comment

by:Chris Dent
Comment Utility

Validation by script is slow, there isn't much of a way around that. You can play around with the different methods of doing it of course, but none are especially quick.

AD Users and Computers can, of course, do this much more quickly because it's not limited by a scripting language. If you were to code and compile a .NET application (for example) you would find any validation would be considerably faster than anything you can do in a script.

We could always try and suggest ways to make what you're doing more efficient. How are you thinking of validating addresses at the moment?

Chris
0
 

Author Comment

by:itsupportoll
Comment Utility
Well, we don't have  to do the validation with a script, of course we are open to a better solution. Is there open source code to compile a application or similar, that's ok with us. Our current situation is that we will use our personell system to "correct" the data in AD/Exchange with correct information. We have approximately 10 000 users. It's not a "one-time-operation", we will continue to transfer data/smtp addresses from our personell system. Since we still are in the development/testing stadium, all bright ideas are welcome to solve this the best way.
0
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
Comment Utility

For us the easiest way to handle validation like this was in this order:

1. Open data connection to external system and read data into Scripting.Dictionary object.
 - If it isn't convenient to configure this list with the SMTP address as the Key then create a second list with <SMTPAddress>, <Key> so they can be very easily linked.

2. Run an AD Query and handle any address that already exists in AD. In my case this is simply a case of discarding them from the imported data (necessity of the design). It logs this using a WriteLog subroutine and counts them with intDiscarded.

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

Set objRootDSE = GetObject("LDAP://RootDSE")
objCommand.CommandText = "SELECT displayName, aDSPath, proxyAddresses " &_
      "FROM 'GC://" & objRootDSE.Get("rootDomainNamingContext") & "'"
Set objRootDSE = Nothing

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 600
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False

Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF
      If Not IsNull(objRecordSet.Fields("proxyAddresses")) Then
            arrAddresses = objRecordSet.Fields("proxyAddresses")
                  
            For Each strAddress in arrAddresses
                  If InStr(1, strAddress, "smtp:", VbTextCompare) Then
                        strAddress = LCase(Replace(strAddress, "smtp:", "", 1, -1, 1))
                        If objData.Exists(strAddress) Then
                              WriteLog "Duplicate Email Address Found:", True
                              WriteLog "Removed: " & strAddress & ": " & objData(strAddress)(0) & " " &_
                                    objData(strAddress)(1) & "; " & objData(strAddress)(2), True
                              WriteLog "Existing Address On: " & objRecordSet.Fields("aDSPath"), True
                              objData.Remove strAddress
                              intDiscarded = intDiscarded + 1
                        End If
                  End If
            Next
      End If
            objRecordSet.MoveNext
Wend
objConnection.Close

Set objRecordSet = Nothing
Set objCommand = Nothing
Set objConnection = Nothing

3. Run normal processes for remaining data.


How useful that kind of solution is depends entirely on how the program runs, if it does masses of data with a relatively low frequency then a minute or so getting every address in the domain is moderately acceptable.

However, if it does a user or two every few minutes then that places a very high load on the script. Let me see if I can build an application and see how quickly that returns.

Chris
0

Featured Post

Do email signature updates give you a headache?

Do you feel like all of your time is spent managing email signatures? Too busy to visit every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Join & Write a Comment

Synchronize a new Active Directory domain with an existing Office 365 tenant
Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now