1

I want to find out users who are not deleted and not disabled. I know I can use two search criteria and use them together there by creating one more search criteria. But as the NOT_IN and IN operators are given I wanted to know how I can use that functionality?

4

2 回答 2

2

另一种方法是执行两个单独的搜索条件,然后将它们组合在一起。

UserManager userManager = Platform.getService(UserManager.class);
SearchCriteria criteria1 = new SearchCriteria(UserManagerConstants.AttributeName.STATUS.getId(), UserManagerConstants.AttributeValues.USER_STATUS_DELETED.getId(), SearchCriteria.Operator.NOT_EQUAL);
SearchCriteria criteria2 = new SearchCriteria(UserManagerConstants.AttributeName.STATUS.getId(), UserManagerConstants.AttributeValues.USER_STATUS_DISABLED.getId(), SearchCriteria.Operator.NOT_EQUAL);
SearchCriteria combined = new SearchCriteria(criteria1, criteria2, SearchCriteria.Operator.AND);


HashMap<String,Object> configParams = new HashMap<String,Object>();
configParams.put("ENDROW", -1);


 List<User>  results = userManager.search(combined, null, configParams);
于 2016-08-10T07:50:42.827 回答
1

您可以使用 OIM 搜索条件,如下所示:

    UserManager usrMgr = oimClient.getService(UserManager.class);
    List<String> listOfStatus =  new ArrayList<String>();
    listOfStatus.add("Disabled");
    listOfStatus.add("Deleted");
    SearchCriteria statusSearchCriteria = new SearchCriteria(UserManagerConstants.AttributeName.STATUS.getId(), listOfStatus, SearchCriteria.Operator.NOT_IN);
    try {
        List<User> retList = usrMgr.search(statusSearchCriteria, null, null);
        System.out.println(retList.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
于 2016-08-08T09:25:55.827 回答