if (domains) oc.append("(objectclass=zimbraDomain)");
    private static String getObjectClassQuery(int flags) {        boolean accounts = (flags & Provisioning.SA_ACCOUNT_FLAG) != 0;         boolean aliases = (flags & Provisioning.SA_ALIAS_FLAG) != 0;        boolean lists = (flags & Provisioning.SA_DISTRIBUTION_LIST_FLAG) != 0;        boolean calendarResources =            (flags & Provisioning.SA_CALENDAR_RESOURCE_FLAG) != 0;        int num = (accounts ? 1 : 0) +                  (aliases ? 1 : 0) +                  (lists ? 1 : 0) +                  (calendarResources ? 1 : 0);        if (num == 0)            accounts = true;        // If searching for user accounts/aliases/lists, filter looks like:        //        //   (&(objectclass=zimbraAccount)!(objectclass=zimbraCalendarResource))        //        // If searching for calendar resources, filter looks like:        //        //   (objectclass=zimbraCalendarResource)        //        // The !resource condition is there in first case because a calendar        // resource is also a zimbraAccount.        //        StringBuffer oc = new StringBuffer();        if (!calendarResources) oc.append("(&");        if (num > 1) oc.append("(|");        if (accounts) oc.append("(objectclass=zimbraAccount)");        if (aliases) oc.append("(objectclass=zimbraAlias)");        if (lists) oc.append("(objectclass=zimbraDistributionList)");        if (calendarResources)            oc.append("(objectclass=zimbraCalendarResource)");        if (num > 1) oc.append(")");        if (!calendarResources)            oc.append("(!(objectclass=zimbraCalendarResource)))");        return oc.toString();    }