[ldap] fix user-filter handling oldstable
authorAlexandre Fayolle <alexandre.fayolle@logilab.fr>
Thu, 09 Dec 2010 14:35:20 +0000
brancholdstable
changeset 6733 627a93027605
parent 6729 1a423eaee782
child 6734 ec9a5efdc451
[ldap] fix user-filter handling
server/sources/ldapuser.py
--- a/server/sources/ldapuser.py	Tue Nov 09 17:17:45 2010 +0100
+++ b/server/sources/ldapuser.py	Thu Dec 09 14:35:20 2010 +0000
@@ -184,7 +184,7 @@
         self.user_login_attr = source_config['user-login-attr']
         self.user_default_groups = splitstrip(source_config['user-default-group'])
         self.user_attrs = dict(v.split(':', 1) for v in splitstrip(source_config['user-attrs-map']))
-        self.user_filter = source_config['user-filter']
+        self.user_filter = source_config.get('user-filter')
         self.user_rev_attrs = {'eid': 'dn'}
         for ldapattr, cwattr in self.user_attrs.items():
             self.user_rev_attrs[cwattr] = ldapattr
@@ -202,8 +202,11 @@
                                                       24*60*60))
 
     def _make_base_filters(self):
-        return [filter_format('(%s=%s)', ('objectClass', o))
-                              for o in self.user_classes] + [self.user_filter]
+        filters =  [filter_format('(%s=%s)', ('objectClass', o))
+                              for o in self.user_classes] 
+        if self.user_filter:
+            filters += [self.user_filter]
+        return filters
 
     def reset_caches(self):
         """method called during test to reset potential source caches"""