Solved

Validate SMTP address in Exchange2003/AD

Posted on 2007-03-30
5
360 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

Are your AD admin tools letting you down?

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

Here's a look at newsworthy articles and community happenings during the last month.
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

615 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