Monday, June 7, 2010

[Exchange] OAB Issue

Hi,
We had recently a strange issue on Outlook clients, regarding the OAB (Offline Address Book).
In fact, we had removed old Exchange 2003 server, which was responsible for the Recipient Update Service (on both Domain/Forest) and the Offline Address Lists (see captures).


















On the client side (Outlook 2003 or 2007 clients), some users/groups do not show on the address list (Global Address List) !


After some research, I found this article which explains well the "Mystery of The Missing Recipients" !


Now, to resolve the issue, I had to search over Active Directory for groups/users that had default SMTP address (on the Email Addresses tab) different from the email address (on the General tab).


To do so, here is a simple VBS that exports all the groups on the domain, with the email address and default SMTP address (made some modifications on this original script):





'Export all groups in AD with custom attributes, here:
'sAMAccountName;Group type;Mail address;Main SMTP address

' This script is designed to be run at a command prompt, using the
' Cscript host. The output can be redirected to a text file.
' For example:
' cscript //nologo DocumentGroups.vbs > groups.txt
'

Option Explicit

Dim adoConnection, adoCommand, objRootDSE, strDNSDomain, strQuery
Dim adoRecordset, strDN, objGroup, Address, MainSMTP

' Use ADO to search Active Directory.
Set adoConnection = CreateObject("ADODB.Connection")
Set adoCommand = CreateObject("ADODB.Command")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnection = adoConnection

' Determine the DNS domain from the RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")

' Search for all groups, return the Distinguished Name of each.
strQuery = "
    & ">;(objectClass=group);distinguishedName;subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False

Set adoRecordset = adoCommand.Execute
If (adoRecordset.EOF = True) Then
    Wscript.Echo "No groups found"
    adoRecordset.Close
    adoConnection.Close
    Set objRootDSE = Nothing
    Set adoConnection = Nothing
    Set adoCommand = Nothing
    Set adoRecordset = Nothing
    Wscript.Quit
End If

'Headers for the output

WScript.Echo "sAMAccountName;Group type;Mail address;Main SMTP address"


' Enumerate all groups, bind to each, and document group members.
Do Until adoRecordset.EOF
    strDN = adoRecordset.Fields("distinguishedName").Value
    ' Escape any forward slash characters with backslash.
    strDN = Replace(strDN, "/", "\/")
    Set objGroup = GetObject("LDAP://" & strDN) '& adspath,proxyAddresses)
     
      'Get the proxyaddresses
    on error resume next
      For Each Address In objGroup.proxyAddresses
            If left(Address,5)= "SMTP:" Then
                  MainSMTP = Address
                  
            End if
      Next
   
    WScript.Echo objGroup.sAMAccountName _
        & ";" & GetType(objGroup.groupType) _
        & " ; " & objGroup.mail & " ; " & MainSMTP
   
    adoRecordset.MoveNext
   
Loop

adoRecordset.Close

' Clean up.
adoConnection.Close
Set objRootDSE = Nothing
Set objGroup = Nothing
Set adoConnection = Nothing
Set adoCommand = Nothing
Set adoRecordset = Nothing

Function GetType(ByVal intType)
    ' Function to determine group type from the GroupType attribute.
    If ((intType And &h01) <> 0) Then
        GetType = "Built-in"
    ElseIf ((intType And &h02) <> 0) Then
        GetType = "Global"
    ElseIf ((intType And &h04) <> 0) Then
        GetType = "Local"
    ElseIf ((intType And &h08) <> 0) Then
        GetType = "Universal"
    End If
    If ((intType And &h80000000) <> 0) Then
        GetType = GetType & "/Security"
    Else
        GetType = GetType & "/Distribution"
    End If
End Function



After the data was exported into a csv file, I used Excel to compare the columns "Mail address" and "Main SMTP address" (the EXACT function), and thus, found only 4 elements and did updated the fields manually.


PS. You can do it via VBS (searching through AD, comparing and updating the data).


Hope it helps.


Imed.

No comments:

Post a Comment

Any suggestions ? comments ? or even errors found on this article..please let me know: