|
Lines 30-35
def bind(lo):
Link Here
|
| 30 |
__all__ = ('user_connection', 'get_user_connection', 'machine_connection', 'get_machine_connection', 'admin_connection', 'get_admin_connection') |
30 |
__all__ = ('user_connection', 'get_user_connection', 'machine_connection', 'get_machine_connection', 'admin_connection', 'get_admin_connection') |
| 31 |
|
31 |
|
| 32 |
|
32 |
|
|
|
33 |
class _WrappedAccess(_access, object): |
| 34 |
|
| 35 |
def __apply(self, func, *args, **kwargs): |
| 36 |
try: |
| 37 |
return func(*args, **kwargs) |
| 38 |
except (ldap.SERVER_DOWN, ldap.UNAVAILABLE, ldap.TIMEOUT, ldap.TIMELIMIT_EXCEEDED, udm_errors.ldapTimeout): |
| 39 |
reset_cache() |
| 40 |
raise |
| 41 |
except udm_errors.ldapError as exc: |
| 42 |
if isinstance(exc.original_exception, (ldap.SERVER_DOWN, ldap.UNAVAILABLE, ldap.TIMEOUT, ldap.TIMELIMIT_EXCEEDED)): |
| 43 |
reset_cache() |
| 44 |
raise |
| 45 |
|
| 46 |
def unbind(self, *args, **kwargs): |
| 47 |
return self.__apply(super(_WrappedAccess, self).unbind, *args, **kwargs) |
| 48 |
|
| 49 |
def whoami(self, *args, **kwargs): |
| 50 |
return self.__apply(super(_WrappedAccess, self).whoami, *args, **kwargs) |
| 51 |
|
| 52 |
def get_schema(self, *args, **kwargs): |
| 53 |
return self.__apply(super(_WrappedAccess, self).get_schema, *args, **kwargs) |
| 54 |
|
| 55 |
def getAttr(self, *args, **kwargs): |
| 56 |
return self.__apply(super(_WrappedAccess, self).getAttr, *args, **kwargs) |
| 57 |
|
| 58 |
def get(self, *args, **kwargs): |
| 59 |
return self.__apply(super(_WrappedAccess, self).get, *args, **kwargs) |
| 60 |
|
| 61 |
def add(self, *args, **kwargs): |
| 62 |
return self.__apply(super(_WrappedAccess, self).add, *args, **kwargs) |
| 63 |
|
| 64 |
def modify(self, *args, **kwargs): |
| 65 |
return self.__apply(super(_WrappedAccess, self).modify, *args, **kwargs) |
| 66 |
|
| 67 |
def modify_s(self, *args, **kwargs): |
| 68 |
return self.__apply(super(_WrappedAccess, self).modify_s, *args, **kwargs) |
| 69 |
|
| 70 |
def searchDn(self, *args, **kwargs): |
| 71 |
return self.__apply(super(_WrappedAccess, self).searchDn, *args, **kwargs) |
| 72 |
|
| 73 |
def search(self, *args, **kwargs): |
| 74 |
return self.__apply(super(_WrappedAccess, self).search, *args, **kwargs) |
| 75 |
|
| 76 |
def getPolicies(self, *args, **kwargs): |
| 77 |
return self.__apply(super(_WrappedAccess, self).getPolicies, *args, **kwargs) |
| 78 |
|
| 79 |
def delete(self, *args, **kwargs): |
| 80 |
return self.__apply(super(_WrappedAccess, self).delete, *args, **kwargs) |
| 81 |
|
| 82 |
def rename(self, *args, **kwargs): |
| 83 |
return self.__apply(super(_WrappedAccess, self).rename, *args, **kwargs) |
| 84 |
|
| 85 |
|
| 33 |
class LDAP(object): |
86 |
class LDAP(object): |
| 34 |
|
87 |
|
| 35 |
_LDAP_CONNECTION = 'ldap_connection' |
88 |
_LDAP_CONNECTION = 'ldap_connection' |
|
Lines 132-137
def getter():
Link Here
|
| 132 |
lo, po = conn |
185 |
lo, po = conn |
| 133 |
except (TypeError, ValueError): |
186 |
except (TypeError, ValueError): |
| 134 |
lo, po = None, None |
187 |
lo, po = None, None |
|
|
188 |
if lo is not None: |
| 189 |
lo.__class__ = _WrappedAccess |
| 135 |
return lo, po |
190 |
return lo, po |
| 136 |
|
191 |
|
| 137 |
def _decorator(func): |
192 |
def _decorator(func): |