Please forgive my rush.
It works. Here it is, use %[1-9].
---

bind = no
version = 3
server_host = ldap://172.16.232.201:389
start_tls = no
search_base = cn=users,cn=accounts,dc=ipa,dc=pthl,dc=hk
scope = sub

query_filter = (uid=%u)

result_attribute = uid

result_format = %u@%2.%1

On Wed, Dec 14, 2022 at 11:01 AM luckydog xf <luckydo...@gmail.com> wrote:

> Hello, Thanks.
>
> Please ignore LDAP here. Whatever attribute names they are, it's just a 
> sample here.
>
> I read the link ldap_table-5.
>
>
> The problem is that there is no way to return one value of an attribute based 
> on the user's input domain.
>
> Because of configuration item
>
> result_attribute = displayName, initials
>
> It returns both.
>
> e.g
>
> postmap -q 'u...@abc.com' ldap://xxx
>
>
> I want it to return the `user` part and domain part based on the user's input.
>
>
> However, it does the job like,
>
> # pseudo code
>
> ldapsearch -h -....  (|(displayName=%s)(initials=%s))  displayName, initials
>
> Appartmently it returns the values of  displayName, initials respectively.
>
> Thanks,
>
> -hongquan
>
> On Tue, Dec 13, 2022 at 11:23:55 AM +0800, luckydog xf wrote:
>
> > # Here is my ldap query
> > bind = no
> > version = 3
> > server_host = ldap://172.16.232.201:389
> > start_tls = no
> > search_base = cn=users,cn=accounts,dc=ipa,dc=pthl,dc=hk
> > scope = sub
> > query_filter = (|(displayName=%s)(initials=%s))
> > result_attribute = displayName, initials
> > result_format = %s
>
> In a well-designed email LDAP schema there are two single-valued valued
> attributes for each user (atribute names may vary, but the semantics
> remain the same):
>
>     * mail
>         - primary (canonical) email address of the user
>
>     * mailRoutingAddress (sometimes "maildrop", ...)
>         - The routing address of the underlying mailbox.
>
> There are then also frequently multi-valued attributes that
> hold one or more email addresses under which the user receives mail:
>
>     * mailAlternateAddress (or with "smtp:" prefix proxyAddresses, ...)
>         - All or additional to "mail" addresses.
>
>
> See LDAP_README for examples.
>
>     https://www.postfix.org/LDAP_README.html
>
> > How to return the only one based on query input?  E.g when the user's
> > input is u...@abc.com, it returns u...@abc.com, vice versa.
>
> See ldap_table(5) for the supported result format syntax, this describes
> some selectors based on the key rather than the lookup result
>
>     https://www.postfix.org/ldap_table.5.html
>
> --
>     Viktor.
>
>
> On Tue, Dec 13, 2022 at 11:15 AM luckydog xf <luckydo...@gmail.com> wrote:
>
>> # Here is my LDAP
>> bind = no
>> version = 3
>> server_host = ldap://172.16.232.201:389
>> start_tls = no
>> search_base = cn=users,cn=accounts,dc=ipa,dc=pthl,dc=hk
>> scope = sub
>>
>> query_filter = (|(displayName=%s)(initials=%s))
>>
>> result_attribute = displayName, initials
>>
>> result_format = %s
>>
>> # my ldap
>> displayName and initials are two different email addresses. One is
>> u...@abc.com, while the other is u...@xyz.com.
>>
>> I use postmap -q 'u...@abc.com', it returns two addresses.
>> How to return the only one based on query input ?
>>
>>

Reply via email to