Fix SQL error on expunge and related ldap provisioning (CO-950)