spring-ldap
spring-ldap copied to clipboard
'in' or 'anyOf' filter criteria
it will be nice to have a 'in' or 'anyOf' filter criteria which is basically: (| (...K1...) (...K2...))
You can do this with the LdapQueryBuilder:
LdapQueryBuilder.where("cn").is("John Doe")
.or("cn").is("Jane Doe")
.or("cn").is("Something Else")
You can also accomplish this with the legacy filter classes, i.e. OrFilter; just add more conditions: http://docs.spring.io/spring-ldap/docs/current/apidocs/index.html?org/springframework/ldap/filter/OrFilter.html
Hi, that's exactly what I'm doing. The thing is that if I have a list or array of values I have to always perform the same procedure:
ContainerCriteria containerCriteria = LdapQueryBuilder.query().where("cn").is(values.get(FIRST_ELEMENT))
for(String value : values.subList(FIRST_ELEMENT, values.size())) {
containerCriteria = containerCriteria.or(keyAttribute).is(value);
}
This can be provided by the library itself
I see. I agree that something like the below would be more efficient:
LdapQueryBuilder.query().where("cn").in(valuesCollection)
and/or
LdapQueryBuilder.query().where("cn").in(value1, value2, value3)
Exactly! The same can be done for & operator (&(...K1...)(...K2...)...). I named our method allOf.