Symptoms
In POA versions 2.6 and 2.6 update 1 mailboxes with Good Link support could not use "GAL Lookup" feature.Cause
GAL Lookup feature uses value from msExchQueryBaseDn attribute and expects that it stores distinguished name (DN) of organization unit (OU) of the organization. Since POA version 2.6 until version 2.6 update 2 this attribute stores the DN of organization's address list.Resolution
- Log on to MPS server (MPS01).
- Copy the following text and paste to the new file fixMsQueryBaseDn.vbs.
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim logFile
Dim logFilename
logFilename = WScript.ScriptFullName & ".log"
Set logFile = fso.CreateTextFile( logFilename, True, True )
Dim argsObj
Set argsObj = WScript.Arguments
If argsObj.Length <> 1 Then
Usage
ElseIf LCase(argsObj(0)) = "all" Then
ProcessItems GetHostingOuDn(), 0
Else
Dim userObj
logFile.WriteLine "Processing " & argsObj(0)
Set userObj = GetObject(argsObj(0))
ProcessUser userObj, GetObject(userObj.parent), 0
End If
WScript.Echo "Executed successfully. See log file " & logFilename & "."
WScript.Quit(0)
Sub Usage()
Dim stdErr
Set stdErr = WScript.StdErr
stdErr.WriteLine "Usage:"
stdErr.WriteLine "1. For fixing all mailboxes in Hosting OU and under it:"
stdErr.WriteLine " cscript.exe /nologo fixMsQueryBaseDn.vbs ALL"
stdErr.WriteLine "2. For fixing only one mailbox:"
stdErr.WriteLine " cscript.exe /nologo fixMsQueryBaseDn.vbs LDAP://<LDAP path of mailbox>"
stdErr.WriteLine "example: cscript.exe /nologo fixMsQueryBaseDn.vbs ""LDAP://cn=john,ou=neverhood inc,ou=provider,ou=Hosting,dc=he,dc=local"""
WScript.Quit(1)
End Sub
Function GetHostingOuDn()
Dim ObjSrv
Set ObjSrv = GetObject("LDAP://RootDse")
Dim dcSuffix
dcSuffix = ObjSrv.Get("defaultNamingContext")
Dim PemConfigObj
Set PemConfigObj = GetObject("LDAP://CN=PEM Configuration,CN=System," & dcSuffix)
Dim xmlObj
Set xmlObj = CreateObject("Microsoft.XMLDOM")
xmlObj.validateOnParse = True
xmlObj.async = False
xmlObj.loadXML(PemConfigObj.Get("adminDescription"))
Dim hostingOuPath
hostingOuPath = xmlObj.SelectSingleNode("//config/hostingOUName").text
GetHostingOuDn = "OU="& hostingOuPath &"," & dcSuffix
End Function
Sub ProcessItems( byval name, byval level )
Dim containerObj
Set containerObj = GetObject("LDAP://"& name )
containerObj.Filter = Array("user", "organizationalUnit")
Dim objUser
For Each objUser In containerObj
Dim x
For each x in objUser.objectClass
If x = "user" Then
ProcessUser objUser, containerObj, level
Exit For
ElseIf x = "organizationalUnit" Then
ProcessOU objUser, level
Exit For
End If
Next
Next
End Sub
Function GetADPropertyAsString(obj, propName)
Dim lastErr
Dim propValue
On Error Resume Next
propValue = obj.Get(propName)
lastErr = Err.Number
On Error Goto 0
' &h8000500D - PROPERTY NOT SET
If (lastErr <> 0) And (lastErr <> &h8000500D) Then Err.Raise lastErr
GetADPropertyAsString = "" & propValue
End Function
Sub ProcessUser( byval objUser, byval parentObj, byval level )
logFile.Write Replace(Space(level), " ", ".") & " user "& objUser.cn & " ... "
If "" = GetADPropertyAsString(objUser, "homeMDB") Then
logFile.WriteLine " not a mailbox - skipping"
ElseIf LCase(GetADPropertyAsString(objUser, "msExchQueryBaseDn")) <> LCase(parentObj.distinguishedName) Then
objUser.Put "msExchQueryBaseDn", parentObj.distinguishedName
objUser.SetInfo
logFile.WriteLine " ""msExchQueryBaseDn"" replaced"
Else
logFile.WriteLine " mailbox is OK"
End If
End Sub
Sub ProcessOU( byval objOu, byval level )
logFile.WriteLine Replace(Space(level), " ", ".") & " Processing "& objOu.distinguishedName
ProcessItems objOu.distinguishedName, level+1
End Sub - Save the file fixMsQueryBaseDn.vbs and execute it from the command line (Programs > Accessories > Command Prompt) to fix mailboxes:
for fixing all hosted mailboxes:
C:\>cscript.exe /nologo fixMsQueryBaseDn.vbs ALL
for fixing individual mailbox:
C:\>cscript.exe /nologo fixMsQueryBaseDn.vbs LDAP://<LDAP path of mailbox> - Check the file fixMsQueryBaseDn.vbs.log for execution results.
Keywords: gal lookup