Home > Exchange 2007, VBScript > OALGen will skip user entry ‘USER’ in address list "\Global Address List’ because the SMTP address " is invalid

OALGen will skip user entry ‘USER’ in address list "\Global Address List’ because the SMTP address " is invalid

This old flame popped up again the other day. Now I seem to remember there was some pre-SP1 issues regarding this, however I wasn’t aware that post-SP1 you could still have problems.

Basically the OAB wont generate entries for users who’s "Email" field in AD is blank (or, in fact, not the same as the "Reply To" address in Exchange).

What do you do if you have multiple users who are incorrect, and you need to fix it (but don’t want to spend hours finding / fixing accounts one at a time)?

You script it of course.

DSQuery user (you may need the -limit flag) > objects.txt

Edit to remove the MS command crap (so that it starts @ your first user)

Save the following script as a vbs file (in the same folder as your objects.txt) and run.

‘ This code will output all users without a email address in AD who should have one.

‘ It will also change the address (if required)

‘ Writted by Stephen Croft from ANS

strtextfile = "objects.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.OpenTextFile(strtextfile, 1, False, 0)

Dim primary

strSMTP = "SMTP"


strobject = objTextFile.ReadLine

strobject = Mid(strobject,2,Len(strobject)-2)

Set objObject = GetObject("LDAP://" & strObject)

on error resume next

‘Gets current Email AD Field?

intEmail = objObject.Get("mail")

‘Finds Primary Email Address from "proxyAddresses"

For Each EMail In objObject.GetEx("proxyAddresses")

primary = InStr(1,EMail,strSMTP,0)

If primary = 1 Then

Intproxy2 = Right(EMail,Len(EMail)-5)

End If


‘Should the user have an address (i.e. is there a primary SMTP)?

If intProxy2 "" Then

‘Echos to command object that is blank, and correct email address.

If intEmail = "" Then

WScript.Echo strobject & " is blank, should be " & Intproxy2

‘Changes AD object (2 lines of code) to have Primary as AD Email

objObject.Put "mail", intProxy2

End if


End If

‘Blanks all variables to keep it functioning properly

intEmail = ""

intProxy = ""

intProxy2 = ""

Loop Until objtextfile.AtEndOfStream = True

The bolded lines change the objects, probably best REM’ing these out and testing what it wants to change (and to what for that matter) by running it from a cmd prompt, and piping it into a output.txt of some sort.

And excuse my scripting, it’s not always the tidiest (but it works goddamn it!! 😛 )

Have fun 🙂

Categories: Exchange 2007, VBScript
  1. LnddMiles
    July 22, 2009 at 5:36 pm

    The best information i have found exactly here. Keep going Thank you

  2. August 13, 2009 at 4:36 am

    Good stuff. For my situation, it was one easier. I only had 3 accounts that were impacted. And I still had an older system that had Exchange 2003 Admin tools on it (and the Active Directory with the Exchange aware DLL). I was able to simply choose ‘Exchange Tasks’ and ‘Remove Exchange Attributes’ on those three objects (they weren’t email enabled accounts) and all was better.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: