summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-04-29 13:39:26 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-04-29 13:39:26 +0200
commit28ae1b011a59eac48989d01928879af5ca0de6a5 (patch)
tree6cd31c0c8e24e6eb6d3996db83df35e1b98c963f /pykolab
parente0835ed698888cebf0ff84e1c6c67e98f9eb5d8f (diff)
downloadpykolab-28ae1b011a59eac48989d01928879af5ca0de6a5.tar.gz
Add a timestamp format modifier, for the purpose of further integration with Active Directory, that uses a .0Z addition to the modifytimestamp.
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/auth/ldap/cache.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/pykolab/auth/ldap/cache.py b/pykolab/auth/ldap/cache.py
index 9452bba..55a47c3 100644
--- a/pykolab/auth/ldap/cache.py
+++ b/pykolab/auth/ldap/cache.py
@@ -62,9 +62,14 @@ class Entry(object):
def __init__(self, uniqueid, result_attr, last_change):
self.uniqueid = uniqueid
self.result_attribute = result_attr
+
+ modifytimestamp_format = conf.get('ldap', 'modifytimestamp_format')
+ if modifytimestamp_format == None:
+ modifytimestamp_format = "%Y%m%d%H%M%SZ"
+
self.last_change = datetime.datetime.strptime(
last_change,
- "%Y%m%d%H%M%SZ"
+ modifytimestamp_format
)
##
@@ -125,9 +130,13 @@ def get_entry(domain, entry, update=True):
db.commit()
_entry = db.query(Entry).filter_by(uniqueid=entry['id']).first()
else:
- if not _entry.last_change.strftime("%Y%m%d%H%M%SZ") == entry['modifytimestamp']:
+ modifytimestamp_format = conf.get('ldap', 'modifytimestamp_format')
+ if modifytimestamp_format == None:
+ modifytimestamp_format = "%Y%m%d%H%M%SZ"
+
+ if not _entry.last_change.strftime(modifytimestamp_format) == entry['modifytimestamp']:
log.debug(_("Updating timestamp for cache entry %r") % (entry['id']), level=8)
- last_change = datetime.datetime.strptime(entry['modifytimestamp'], "%Y%m%d%H%M%SZ")
+ last_change = datetime.datetime.strptime(entry['modifytimestamp'], modifytimestamp_format)
_entry.last_change = last_change
db.commit()
_entry = db.query(Entry).filter_by(uniqueid=entry['id']).first()
@@ -163,7 +172,12 @@ def init_db(domain):
def last_modify_timestamp(domain):
db = init_db(domain)
last_change = db.query(Entry).order_by(desc(Entry.last_change)).first()
+
+ modifytimestamp_format = conf.get('ldap', 'modifytimestamp_format')
+ if modifytimestamp_format == None:
+ modifytimestamp_format = "%Y%m%d%H%M%SZ"
+
if not last_change == None:
- return last_change.last_change.strftime("%Y%m%d%H%M%SZ")
+ return last_change.last_change.strftime(modifytimestamp_format)
- return datetime.datetime(1900, 01, 01, 00, 00, 00).strftime("%Y%m%d%H%M%SZ")
+ return datetime.datetime(1900, 01, 01, 00, 00, 00).strftime(modifytimestamp_format)