我想找出未删除但未禁用的用户。我知道我可以使用两个搜索条件,并通过再创建一个搜索条件将它们一起使用。但是当给出NOT_IN和IN运算符时,我想知道如何使用该功能?
答案 0 :(得分: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);
答案 1 :(得分: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();
}