0

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?

Chaitanya K
  • 1,827
  • 4
  • 32
  • 67

2 Answers2

2

Another way to do this is to do two seperate Search Criteria and then combine them in one.

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);
Ioanna Katsanou
  • 484
  • 2
  • 7
  • 24
0

you can use the OIM search criteria as follows:

    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();
    }
Kunal Varpe
  • 419
  • 1
  • 5
  • 28
  • 1
    i believe this answer is incorrect, as the documentation for the search method of UserManager states that "The SearchCriteria Operators supported are AND, OR, NOT, GREATER_THAN, GREATER_EQUAL, LESS_THAN, LESS_EQUAL, EQUAL and NOT_EQUAL. For additional comparisons like contains the SearchCriteria Operator will be EQUAL with value to be searched will be '**' " The other answer seems like the correct solution – Alvin Baena Apr 06 '17 at 15:48