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)
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)
‘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
‘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 🙂