use of org.springframework.ldap.query.ContainerCriteria in project apollo by ctripcorp.
the class LdapUserService method findByUserIds.
@Override
public List<UserInfo> findByUserIds(List<String> userIds) {
if (CollectionUtils.isEmpty(userIds)) {
return Collections.emptyList();
}
if (StringUtils.isNotBlank(groupSearch)) {
return searchUserInfoByGroup(groupBase, groupSearch, null, userIds);
}
ContainerCriteria criteria = query().where(loginIdAttrName).is(userIds.get(0));
userIds.stream().skip(1).forEach(userId -> criteria.or(loginIdAttrName).is(userId));
return ldapTemplate.search(ldapQueryCriteria().and(criteria), ldapUserInfoMapper);
}
use of org.springframework.ldap.query.ContainerCriteria in project apollo by ctripcorp.
the class LdapUserService method searchUsers.
@Override
public List<UserInfo> searchUsers(String keyword, int offset, int limit) {
List<UserInfo> users = new ArrayList<>();
if (StringUtils.isNotBlank(groupSearch)) {
List<UserInfo> userListByGroup = searchUserInfoByGroup(groupBase, groupSearch, keyword, null);
users.addAll(userListByGroup);
return users.stream().collect(collectingAndThen(toCollection(() -> new TreeSet<>((o1, o2) -> {
if (o1.getUserId().equals(o2.getUserId())) {
return 0;
}
return -1;
})), ArrayList::new));
}
ContainerCriteria criteria = ldapQueryCriteria();
if (!Strings.isNullOrEmpty(keyword)) {
criteria.and(query().where(loginIdAttrName).like(keyword + "*").or(userDisplayNameAttrName).like(keyword + "*"));
}
users = ldapTemplate.search(criteria, ldapUserInfoMapper);
return users;
}
use of org.springframework.ldap.query.ContainerCriteria in project apollo by ctripcorp.
the class LdapUserService method ldapQueryCriteria.
/**
* 查询条件
*/
private ContainerCriteria ldapQueryCriteria() {
ContainerCriteria criteria = query().searchScope(SearchScope.SUBTREE).where("objectClass").is(objectClassAttrName);
if (memberOf.length > 0 && !StringUtils.isEmpty(memberOf[0])) {
ContainerCriteria memberOfFilters = query().where(MEMBER_OF_ATTR_NAME).is(memberOf[0]);
Arrays.stream(memberOf).skip(1).forEach(filter -> memberOfFilters.or(MEMBER_OF_ATTR_NAME).is(filter));
criteria.and(memberOfFilters);
}
return criteria;
}
Aggregations