Solved

Validate SMTP address in Exchange2003/AD

Posted on 2007-03-30
5
348 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
ID: 18825679

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
ID: 18826829
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
ID: 18834844

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
Find out what you should include to make the best professional email signature for your organization.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

864 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

16 Experts available now in Live!

Get 1:1 Help Now