From 8a7394a5505145bb8a578bf033a2a55fca132b47 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 4 Dec 2015 11:23:49 +0100 Subject: [PATCH] [FIX] auth_ldap: filter format The LDAP method filter_format(filter_template,assertion_values) requires that the length of assertion_values matches the count of %s in filter_template. If not, a TypeError exception is thrown. This fix catches the exception and displays an understandable error message instead. opw-608126 opw-657370 --- addons/auth_ldap/users_ldap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/auth_ldap/users_ldap.py b/addons/auth_ldap/users_ldap.py index 6a6414c0037..4ab6a918382 100644 --- a/addons/auth_ldap/users_ldap.py +++ b/addons/auth_ldap/users_ldap.py @@ -96,7 +96,11 @@ class CompanyLDAP(osv.osv): return False entry = False - filter = filter_format(conf['ldap_filter'], (login,)) + try: + filter = filter_format(conf['ldap_filter'], (login,)) + except TypeError: + _logger.warning('Could not format LDAP filter. Your filter should contain one \'%s\'.') + return False try: results = self.query(conf, filter)