From: Wade Berrier Date: Sat, 19 Jan 2013 21:05:59 +0000 (-0700) Subject: Add query filter section (in order to pare down results) X-Git-Tag: v0.1~27^2~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=883e45d5271a1ff7239bd056b835e90f1cdce1d4;p=mutt-ldap.git Add query filter section (in order to pare down results) --- 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,