From 69700d0ce9a2552efadedefa962cd08dfcbf3ced Mon Sep 17 00:00:00 2001 From: kakwa Date: Wed, 29 Jul 2015 00:09:15 +0200 Subject: [PATCH] more encoding fixes --- ldapcherry/backend/backendLdap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ldapcherry/backend/backendLdap.py b/ldapcherry/backend/backendLdap.py index cf3b8f1..700778c 100644 --- a/ldapcherry/backend/backendLdap.py +++ b/ldapcherry/backend/backendLdap.py @@ -233,7 +233,7 @@ class Backend(ldapcherry.backend.Backend): user_filter = self.user_filter_tmpl % { 'username': username } - + user_filter = self._str(user_filter) r = self._search(user_filter, attrs, self.userdn) if len(r) == 0: @@ -246,9 +246,13 @@ class Backend(ldapcherry.backend.Backend): return dn_entry def _str(self, s): + if s is None: + return None return s.encode('utf-8') def _uni(self, s): + if s is None: + return None return s.decode('utf-8', 'ignore') def auth(self, username, password):