From 883e45d5271a1ff7239bd056b835e90f1cdce1d4 Mon Sep 17 00:00:00 2001 From: Wade Berrier Date: Sat, 19 Jan 2013 14:05:59 -0700 Subject: [PATCH] Add query filter section (in order to pare down results) --- mutt-ldap.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mutt-ldap.py b/mutt-ldap.py index 92607ed..94e44b9 100755 --- a/mutt-ldap.py +++ b/mutt-ldap.py @@ -54,6 +54,8 @@ CONFIG.add_section('auth') CONFIG.set('auth', 'user', '') CONFIG.set('auth', 'password', '') CONFIG.set('auth', 'gssapi', 'no') +CONFIG.add_section('query') +CONFIG.set('query', 'filter', '') # only match entries according to this filter CONFIG.read(os.path.expanduser('~/.mutt-ldap.rc')) def connect(): @@ -89,6 +91,9 @@ def search(query, connection=None): filterstr = u'(|{})'.format( u' '.join([u'({}=*{}{})'.format(field, query, post) for field in ['cn', 'displayName', 'uid', 'mail']])) + query_filter = CONFIG.get('query', 'filter') + if query_filter: + filterstr = u'(&({}){})'.format(query_filter, filterstr) r = connection.search_s( CONFIG.get('connection', 'basedn'), ldap.SCOPE_SUBTREE, -- 2.26.2