How to exclude a shared contact by mail attribute

Problem

You are unable to exclude all the Shared Contacts from a sync using Google Cloud Directory Sync, that have a specific string in the mail attribute. For example, you want to exclude the email addresses of Shared Contacts that have test in the email address.

Environment

  • All versions of Google Cloud Directory Sync

Solution

The option to make GCDS retrieve or sync shared contacts without a specific string in the email address, is to modify the search rule by following these steps:
  1. Go to the Configuration Manager > Shared Contacts > Search Rules.
  2. Type a search rule like: 
    (&(objectCategory=contact)(mail=*)(!(mail=*test*)))
  3. Save the XML file (with a different name as a suggestion) and execute a simulation.
  4. The search rule will retrieve all the objects that are type contact and that have a mail, but do not have the string *test* in the mail attribute.

Cause

The Exclusion rules, do not show an option to exclude by mail. It only shows Sync Key in the Exclude type field.