Script to Delete Galcontacts.db for Multiple Microsoft Office Communicator 2007 R2 and Lync 2010 Users


When a Communicator 2007 R2 or Lync 2010 client is unable to synchronize address book files, manually deleting the Galcontacts.db and Galcontacts.idx helps resolve the problem. However, manually deleting the files is not a scalable solution for an organization that has more than 25 users. This article describes a script that can help you automatically delete Galcontacts.db and Galcontacts.idx files.

Author: Edwin Joseph

Publication date: December 22, 2011

Product versions: Microsoft Lync 2010 and Microsoft Office Communicator 2007 R2

Introduction

In Microsoft Office Communication Server 2007 R2 and Microsoft Lync server 2010, the Address Book Service (ABServer.exe) generates two sets of files which are used by two groups of clients. For clients with sufficient local storage space, ABServer.exe generates a full address book file that contains a large set of user and contact object attributes.

This file is downloaded from server and is stored in GalContact.db file on the client by Microsoft Office Communicator 2007 R2. Sometimes, due to possible corruption in the GalContacts.db or GalContacts.Idx file, the client looks for an address book file that does not exist. This usually occurs when the Address Book Server is unable to generate an address book file for more than 3 days.

This article helps administrators delete the SIP profile on a user’s computer which in turn deletes the Galcontacts.db and Galcontacts.idx file. This may be necessary when a user has corruption issues with the Galcontacts.db and Galcontacts.idx file. The script that can be deployed using automatically applied group policy. The script can be placed on a file share so that user can execute the script on their workstation. This automated process deletes the Galcontacts.db and Galcontacts.idx files for multiple users.

Address Book Service Background

As previous discussed, in Office Communication Server 2007 R2 and Lync Server 2010, the Address Book Service (ABServer.exe) generates two sets of files used by two groups of clients. For clients with sufficient local storage space, the ABServer.exe generates a file that contains a full address book that contains a large set of user and contact object attributes. To optimize download efficiency, it also generates up to 29 delta files that contain incremental updates containing the last one day, two days, and up to 29 days’ worth of changes. These files have the *.lsabs file extension.

When Communicator and Lync clients access and successfully connect to the Address Book Service URL for the first time, the client attempts to download the latest complete address book file. On subsequent days, the client attempts to download a delta file based on the last full synchronization date. During daily client usage, this delta file is based on the previous day’s changes. If the client is offline for a day or more, it determines which delta file it must download to get up to date. For example, if the client is offline from Friday afternoon to Monday morning, it will attempt to download a delta file containing 3 days of changes. If the client is offline for more than 30 days, it must download the full address book file. The client stores this information in the local database, called GalContacts.db.

If the GalContacts.db or the GalContacts.Idx file becomes corrupted, a client may keep looking for address book file that does not exist. This may occur when the Address Book Server is unable to generate the address book file for more than three days. There are several reasons why the Address Book Service is not able to generate an address book file, ranging from Backend SQL Server connectivity issues to network share issues.

In situations when Communicator or Lync is unable to synchronize the address book files, manually deleting the Galcontacts.db and Galcontacts.idx from the users workstation helps solve the problem. However, this is not a scalable solution for large organizations. To solve this problem, I have written a script that deletes the SIP profile folder on the user’s computer which in turn deletes the Galcontacts.db and Galcontacts.idx file.

Note: When restarting Communicator or Lync after deleting the SIP profile folder, the client will attempt to download the address book file resulting in heavy bandwidth consumption.

For more information see: Address Book Server: Address Book File Download Service.

The Script

'==========================================================================

'

' NAME:  Delete sip profile

'

' BY Edwin Joseph

'

' COMMENT: this script delete the sip profile for the user from machine 

' the purpose here is delete the galcontact.db file so that communicator can download a new one 

'==========================================================================

 

Option Explicit

Dim objShell12

Dim objUserEnv

Dim strUserPro

Dim userProfile,SipProfile

Dim OSType

 

Set objShell12=CreateObject("WScript.Shell")

 

Set objUserEnv=objShell12.Environment("User")

 

strUserPro= objShell12.ExpandEnvironmentStrings(objUserEnv("TEMP"))

userProfile = objShell12.ExpandEnvironmentStrings("%userprofile%")

 

DeleteSip strUserPro 'delete user sip profile

 

 

 'delete sip Profile

 'the sip profile path is diffrent according to OS Type

OSType=FindOSType

 

If OSType="Windows 7" Or OSType="Windows Vista" Then

SipProfile=userProfile & "AppDataLocalMicrosoftcommunicator"

ElseIf  OSType="Windows 2003" Or OSType="Windows XP" Then

SipProfile=userProfile & "Local SettingsApplication DataMicrosoftcommunicator"

End If

 

DeleteSip SipProfile

'this is also to delete user sip profile

SipProfile=SipProfile & "Sip_*"

DeleteSip SipProfile

WScript.Quit

Sub DeleteSip (strSipPath)

On Error Resume Next

Dim objFSO

Dim objFolder,objDir

Dim i

Set objFSO=CreateObject("Scripting.FileSystemObject")

Set objFolder=objFSO.GetFolder(strSipPath)

 

'delete folder

For i=0 To 10

                For Each objDir In objFolder.SubFolders

                objDir.Delete True

                Next

Next

'clear all objects

Set objFSO=Nothing

Set objFolder=Nothing

Set objDir=Nothing

End Sub

 

Function FindOSType

    'Defining Variables

    Dim objWMI, objItem, colItems

    Dim OSVersion, OSName

 

Comments (7)
  1. Hi Delp man,

    The reason that we deleting the sip_profile due to the fact I wanted this script to be simple and without depending on user inputs in view of reducing the humin effort involved. also i dint want the scrip to burden the machine performance by doing too many queries to gather information regarding user sip Uri.

    Hope this helpful

  2. paul says:

    Hi, as Edwin stated the galdownloadinitialdelay=0 registry entries would be very beneficial as well. We recently deployed Lync 2013 in an Office 2010 environment, both the registry keys + deleting GalContact.db + idx seems to do the trick to fix address
    book sync. I’m no coder, but would it be a lot of work to modify the script to include the registry keys as well ?

Comments are closed.

Skip to main content