From 978901ab11aa2355dcb7fdd2ab6c675cf861b5d5 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 15 Aug 2012 10:13:20 -0400 Subject: [PATCH] Also search on displayName in mutt-ldap.py and ldap-jpeg.py. Also prefer displayName to cn when formatting names. --- mutt-ldap.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mutt-ldap.py b/mutt-ldap.py index 059b25c..7c51d85 100755 --- a/mutt-ldap.py +++ b/mutt-ldap.py @@ -87,7 +87,7 @@ def search(query, connection=None): post = '*' filterstr = '(|%s)' % ( u' '.join([u'(%s=*%s%s)' % (field, query, post) - for field in ['cn', 'uid', 'mail']])) + for field in ['cn', 'displayName', 'uid', 'mail']])) r = connection.search_s( CONFIG.get('connection', 'basedn'), ldap.SCOPE_SUBTREE, @@ -100,8 +100,9 @@ def search(query, connection=None): def format_entry(entry): cn,data = entry if 'mail' in data: + name = data.get('displayName', data['cn'])[-1] for m in data['mail']: - yield email.utils.formataddr((data['cn'][-1], m)) + yield email.utils.formataddr((name, m)) if __name__ == '__main__': -- 2.26.2