server/sources/ldapuser.py
brancholdstable
changeset 5455 3dc47a52dd19
parent 5428 98e0b7421e51
child 5456 d040889fac4e
equal deleted inserted replaced
5441:9ffda7b0d772 5455:3dc47a52dd19
    42 import ldap
    42 import ldap
    43 from ldap.ldapobject import ReconnectLDAPObject
    43 from ldap.ldapobject import ReconnectLDAPObject
    44 from ldap.filter import filter_format, escape_filter_chars
    44 from ldap.filter import filter_format, escape_filter_chars
    45 from ldapurl import LDAPUrl
    45 from ldapurl import LDAPUrl
    46 
    46 
       
    47 from logilab.common.configuration import time_validator
    47 from cubicweb import AuthenticationError, UnknownEid, RepositoryError
    48 from cubicweb import AuthenticationError, UnknownEid, RepositoryError
    48 from cubicweb.server.utils import cartesian_product
    49 from cubicweb.server.utils import cartesian_product
    49 from cubicweb.server.sources import (AbstractSource, TrFunc, GlobTrFunc,
    50 from cubicweb.server.sources import (AbstractSource, TrFunc, GlobTrFunc,
    50                                      ConnectionWrapper, TimedCache)
    51                                      ConnectionWrapper, TimedCache)
    51 
    52 
   184             self.user_rev_attrs[cwattr] = ldapattr
   185             self.user_rev_attrs[cwattr] = ldapattr
   185         self.base_filters = [filter_format('(%s=%s)', ('objectClass', o))
   186         self.base_filters = [filter_format('(%s=%s)', ('objectClass', o))
   186                               for o in self.user_classes]
   187                               for o in self.user_classes]
   187         self._conn = None
   188         self._conn = None
   188         self._cache = {}
   189         self._cache = {}
   189         ttlm = int(source_config.get('cache-life-type', 2*60))
   190         ttlm = time_validator(None, None,
       
   191                               source_config.get('cache-life-time', 2*60))
   190         self._query_cache = TimedCache(ttlm)
   192         self._query_cache = TimedCache(ttlm)
   191         self._interval = int(source_config.get('synchronization-interval',
   193         self._interval = time_validator(None, None,
       
   194                                         source_config.get('synchronization-interval',
   192                                                24*60*60))
   195                                                24*60*60))
   193 
   196 
   194     def reset_caches(self):
   197     def reset_caches(self):
   195         """method called during test to reset potential source caches"""
   198         """method called during test to reset potential source caches"""
   196         self._cache = {}
   199         self._cache = {}