LDAP multiple values attributes filter
10,502
A search term like this should help:
(&([email protected])(mail=*domain1.tld))
LDAP search terms get combined like this:
(Operator(filter)(filter)(filter)...)
with Operator
being &
(AND), |
(OR) and !
(NOT).
Related videos on Youtube
Author by
Anatoly
Updated on September 18, 2022Comments
-
Anatoly almost 2 years
Can't find same question, but I think it's regular issue. I have LDAP user:
dn: uid=alise,ou=peoples,dc=acme,dc=com objectClass: inetOrgPerson objectClass: top cn: alise sn: alise uid: alise userPassword: {SCHEME}password mail: [email protected] mail: [email protected] mailAlias: [email protected] mailAlias: [email protected]
I need to return mail attribute, but filtered by domain. For example if I search:
ldapsearch -xLLL -b ou=peoples,dc=withsound,dc=ru '([email protected])' mail
I get:
dn: uid=alise,ou=peoples,dc=acme,dc=com mail: [email protected] mail: [email protected]
But I need something like:
ldapsearch -xLLL -b ou=peoples,dc=withsound,dc=ru '([email protected])' mail=*domain1.tld dn: uid=alise,ou=peoples,dc=acme,dc=com mail: [email protected]
I can't simply use | grep domain1.tld cause I use LDAP search in Postfix
I really don't want to separate user and make only one email field...
-
Anatoly almost 7 yearsUnfortunately it returns 2 value. Cause one of the value of "mail" attribute return TRUE and we required "mail" attribute as a result =( I found there's no option to return 1 value of multi-valued attribute =(
-
natxo asenjo almost 7 yearsIf Sven's tip does not work for your needs, then you'll need to script this with your favourite language and create a Postfix map file.