# HG changeset patch # User Pierre-Yves David # Date 1366818049 -7200 # Node ID 4cba95ef47387dadd3519752cf5a3d884c9188fc # Parent 43fd866e8f8a5eadfd7bb15aa0ec156422c243ec [ldap] handle modification date We are now able to import modification date from ldap. diff -r 43fd866e8f8a -r 4cba95ef4738 server/ldaputils.py --- a/server/ldaputils.py Wed Apr 24 17:39:10 2013 +0200 +++ b/server/ldaputils.py Wed Apr 24 17:40:49 2013 +0200 @@ -32,6 +32,8 @@ from __future__ import division # XXX why? +from datetime import datetime + import ldap from ldap.ldapobject import ReconnectLDAPObject from ldap.filter import filter_format @@ -160,7 +162,7 @@ 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 = {'dn': 'eid'} + self.user_attrs = {'dn': 'eid', 'modifyTimestamp': 'modification_date'} 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)) @@ -340,6 +342,8 @@ if not value.startswith('{SSHA}'): value = utils.crypt_password(value) itemdict[key] = Binary(value) + elif self.user_attrs.get(key) == 'modification_date': + itemdict[key] = datetime.strptime(value[0], '%Y%m%d%H%M%SZ') else: value = [unicode(val, 'utf-8', 'replace') for val in value] if len(value) == 1: diff -r 43fd866e8f8a -r 4cba95ef4738 sobjects/ldapparser.py --- a/sobjects/ldapparser.py Wed Apr 24 17:39:10 2013 +0200 +++ b/sobjects/ldapparser.py Wed Apr 24 17:40:49 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', 'eid')) + non_attribute_keys = set(('email', 'eid', 'member', 'modification_date')) @cachedproperty def searchfilterstr(self):