Reputation: 33359
Let's say an LDAP schema has an attribute called "Food", which stores people's favorite foods. It's a multi-valued attribute so there can be many different values listed for one person.
A partial dump of such an entry might look like this:
dn: cn=joe,ou=people,dc=company,dc=com
cn: joe
Food: pizza
Food: beer
Food: wings
So we can see that Joe really likes pizza, beer and wings.
Then let's say I want to match Joe up with other users who also enjoy pizza, beer and/or wings but not users who enjoy, say, brussels sprouts or cauliflower.
Is there a search filter that returns entries with one or more of "pizza", "beer" and "wings" -- and nothing else -- in the Food attribute?
The first part, looking for any or all of those three values, is easy:
(|(Food=pizza)(Food=beer)(Food=wings))
But how do I tell it to exclude entries which have any values other than those three?
Obviously I can post-process the search results and manually throw out any entries that have bad values, but I'd rather not do that if I can avoid it.
Upvotes: 2
Views: 3950
Reputation: 4100
Would negating this filter work?
(&(!(Food=pizza))(!(Food=beer))(!(Food=wings))
So that you get (!(&(!(Food=pizza))(!(Food=beer))(!(Food=wings)))
I doubt that is in any way efficient. Not sure if it would work either...
Upvotes: 0
Reputation: 714
If the "any values other than those three" are known and limited, you might be looking for something like this:
(&(|(Food=pizza)(Food=beer)(Food=wings))(|(!(Food=cauliflower))(!(Food=sprouts))))
Basically, you make a compound filter that says "It's pizza OR beer OR wings OR any combination of those, AND it's not cauliflower OR sprouts."
I'm not sure if there's a great way to say, "It's ONLY pizza OR beer OR wings OR any combination of those." The best way I can imagine involves creating an extremely verbose filter with all possible values in it. Maybe someone else knows a better way?
Upvotes: 1