logging.info("Successfully authenticated as %s" % self.ldap.whoami_s())
def _query(self, query, attrlist=None, limit=0, search_base=None):
- logging.debug("Performing LDAP query: %s" % query)
+ logging.debug("Performing LDAP query (%s): %s" \
+ % (search_base or self.search_base, query))
t = time.time()
"""
Fetches all attributes for the given distinguished name
"""
- results = self._query("(objectClass=*)", search_base=dn, limit=1)
+ results = self._query("(objectClass=*)", search_base=dn, limit=1,
+ attrlist=("*", "createTimestamp", "modifyTimestamp"))
for dn, attrs in results:
return attrs
return Account(self.backend, dn, attrs)
+ def get_created_after(self, ts):
+ t = ts.strftime("%Y%m%d%H%M%SZ")
+
+ return self._search("(&(objectClass=person)(createTimestamp>=%s))" % t)
+
def search(self, query):
# Search for exact matches
accounts = self._search(
for value in self._get_strings(key):
yield phonenumbers.parse(value, None)
+ def _get_timestamp(self, key):
+ value = self._get_string(key)
+
+ # Parse the timestamp value and returns a datetime object
+ return datetime.datetime.strptime(value, "%Y%m%d%H%M%SZ")
+
def _modify(self, modlist):
logging.debug("Modifying %s: %s" % (self.dn, modlist))
return groups
+ # Created/Modified at
+
+ @property
+ def created_at(self):
+ return self._get_timestamp("createTimestamp")
+
+ @property
+ def modified_at(self):
+ return self._get_timestamp("modifyTimestamp")
+
# Address
@property