[ldap] an empty 'user-base-dn' disable the user importation process,
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 23 Apr 2013 16:07:02 +0200
changeset 8906 ed35d984ff28
parent 8905 c8fc3e3b46e4
child 8907 ddeb02b02222
[ldap] an empty 'user-base-dn' disable the user importation process, The same semantic will be used for group. We start by using it for user for the sake of consistency.
server/ldaputils.py
sobjects/ldapparser.py
--- a/server/ldaputils.py	Tue Apr 23 15:46:09 2013 +0200
+++ b/server/ldaputils.py	Tue Apr 23 16:07:02 2013 +0200
@@ -88,8 +88,8 @@
 
         ('user-base-dn',
          {'type' : 'string',
-          'default': 'ou=People,dc=logilab,dc=fr',
-          'help': 'base DN to lookup for users',
+          'default': '',
+          'help': 'base DN to lookup for users; disable user importation mechanism if unset',
           'group': 'ldap-source', 'level': 1,
           }),
         ('user-scope',
--- a/sobjects/ldapparser.py	Tue Apr 23 15:46:09 2013 +0200
+++ b/sobjects/ldapparser.py	Tue Apr 23 16:07:02 2013 +0200
@@ -42,11 +42,13 @@
     @cachedproperty
     def source_entities_by_extid(self):
         source = self.source
-        return dict((userdict['dn'], userdict)
-                    for userdict in source._search(self._cw,
-                                                   source.user_base_dn,
-                                                   source.user_base_scope,
-                                                   self.searchfilterstr))
+        if source.user_base_dn.strip():
+            return dict((userdict['dn'], userdict)
+                        for userdict in source._search(self._cw,
+                                                       source.user_base_dn,
+                                                       source.user_base_scope,
+                                                       self.searchfilterstr))
+        return {}
 
     def process(self, url, raise_on_error=False):
         """IDataFeedParser main entry point"""