accounts = d.searchAccounts(query, attrsToGet, sortBy, isSortAscending, flags);
accounts = Provisioning.getInstance().searchAccounts(d, query, attrsToGet, sortBy, isSortAscending, flags);
    private void doSearchAccounts(String[] args) throws ServiceException, ArgException {        boolean verbose = false;        int i = 1;                if (args.length < i+1) {            usage();            return;        }        if (args[i].equals("-v")) {            verbose = true;            i++;            if (args.length < i-1) {                usage();                return;                            }        }                if (args.length < i+1) {            usage();            return;        }                    String query = args[i];        Map attrs = getMap(args, i+1);//        int iPageNum = 0;//        int iPerPage = 0;                String limitStr = (String) attrs.get("limit");        int limit = limitStr == null ? Integer.MAX_VALUE : Integer.parseInt(limitStr);                String offsetStr = (String) attrs.get("offset");        int offset = offsetStr == null ? 0 : Integer.parseInt(offsetStr);                		String sortBy  = (String)attrs.get("sortBy");		String sortAscending  = (String) attrs.get("sortAscending");		boolean isSortAscending = (sortAscending != null) ? "1".equalsIgnoreCase(sortAscending) : true;            String attrsStr = (String)attrs.get("attrs");		String[] attrsToGet = attrsStr == null ? null : attrsStr.split(",");        String applyCosStr  = (String) attrs.get("applyCos");        boolean applyCos = (applyCosStr != null) ? "1".equalsIgnoreCase(applyCosStr) : true;            String typesStr = (String) attrs.get("types");        int flags = Provisioning.SA_ACCOUNT_FLAG|Provisioning.SA_ALIAS_FLAG|Provisioning.SA_DISTRIBUTION_LIST_FLAG|Provisioning.SA_CALENDAR_RESOURCE_FLAG;                if (typesStr != null) {            flags = 0;            if (typesStr.indexOf("accounts") != -1) flags |= Provisioning.SA_ACCOUNT_FLAG;            if (typesStr.indexOf("aliases") != -1) flags |= Provisioning.SA_ALIAS_FLAG;            if (typesStr.indexOf("distributionlists") != -1) flags |= Provisioning.SA_DISTRIBUTION_LIST_FLAG;            if (typesStr.indexOf("resources") != -1) flags |= Provisioning.SA_CALENDAR_RESOURCE_FLAG;            if (typesStr.indexOf("domains") != -1) flags |= Provisioning.SA_DOMAIN_FLAG;        }        String domainStr = (String)attrs.get("domain");        List accounts;        if (domainStr != null) {            Domain d = lookupDomain(domainStr);            accounts = d.searchAccounts(query, attrsToGet, sortBy, isSortAscending, flags);        } else {            //accounts = mProvisioning.searchAccounts(query, attrsToGet, sortBy, isSortAscending, Provisioning.SA_ACCOUNT_FLAG);            accounts = mProv.searchAccounts(query, attrsToGet, sortBy, isSortAscending, flags);        }        //ArrayList accounts = (ArrayList) mProvisioning.searchAccounts(query);        for (int j=offset; j < offset+limit && j < accounts.size(); j++) {            NamedEntry account = (NamedEntry) accounts.get(j);            if (verbose) {                if (account instanceof Account)                    dumpAccount((Account)account, applyCos);                else if (account instanceof Alias)                    dumpAlias((Alias)account);                else if (account instanceof DistributionList)                    dumpDistributionList((DistributionList)account);                else if (account instanceof Domain)                    dumpDomain((Domain)account);            } else {                System.out.println(account.getName());            }        }    }    