[ldap] refactor attributes mapping handling
* use explicit attributes lists when calling ldap search
* direct and reverse attributes maps contains now the same elements.
--- a/server/ldaputils.py Wed Apr 24 14:00:52 2013 +0200
+++ b/server/ldaputils.py Wed Apr 24 17:39:10 2013 +0200
@@ -160,10 +160,9 @@
self.user_base_scope = globals()[typedconfig['user-scope']]
self.user_login_attr = typedconfig['user-login-attr']
self.user_default_groups = typedconfig['user-default-group']
- self.user_attrs = typedconfig['user-attrs-map']
- self.user_rev_attrs = {'eid': 'dn'}
- for ldapattr, cwattr in self.user_attrs.items():
- self.user_rev_attrs[cwattr] = ldapattr
+ self.user_attrs = {'dn': 'eid'}
+ self.user_attrs.update(typedconfig['user-attrs-map'])
+ self.user_rev_attrs = dict((v, k) for k, v in self.user_attrs.iteritems())
self.base_filters = [filter_format('(%s=%s)', ('objectClass', o))
for o in typedconfig['user-classes']]
if typedconfig['user-filter']:
--- a/sobjects/ldapparser.py Wed Apr 24 14:00:52 2013 +0200
+++ b/sobjects/ldapparser.py Wed Apr 24 17:39:10 2013 +0200
@@ -32,7 +32,7 @@
__regid__ = 'ldapfeed'
# attributes that may appears in source user_attrs dict which are not
# attributes of the cw user
- non_attribute_keys = set(('email',))
+ non_attribute_keys = set(('email', 'eid'))
@cachedproperty
def searchfilterstr(self):
@@ -43,11 +43,13 @@
def source_entities_by_extid(self):
source = self.source
if source.user_base_dn.strip():
+ attrs = map(str, source.user_attrs.keys())
return dict((userdict['dn'], userdict)
for userdict in source._search(self._cw,
source.user_base_dn,
source.user_base_scope,
- self.searchfilterstr))
+ self.searchfilterstr,
+ attrs))
return {}
def process(self, url, raise_on_error=False):