Solved

Validate SMTP address in Exchange2003/AD

Posted on 2007-03-30
5
358 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 71

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 71

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

751 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