예제 #1
0
def ldap_exception_handler(func):
    """LDAP operation wrapper, takes care of exception handling.
    """
    @wraps(func)
    def handler(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except ldap.SERVER_DOWN, e:
            raise exceptions.ServerDown(exceptions.desc(e))
        except ldap.TIMEOUT, e:
            raise exceptions.Timeout(exceptions.desc(e))
예제 #2
0
 def handler(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except ldap.SERVER_DOWN, e:
         raise exceptions.ServerDown(exceptions.desc(e))
예제 #3
0
log = logging.getLogger(__name__)


def ldap_exception_handler(func):
    """LDAP operation wrapper, takes care of exception handling.
    """
    @wraps(func)
    def handler(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except ldap.SERVER_DOWN, e:
            raise exceptions.ServerDown(exceptions.desc(e))
        except ldap.TIMEOUT, e:
            raise exceptions.Timeout(exceptions.desc(e))
        except ldap.CONNECT_ERROR, e:
            raise exceptions.ConnectionError(exceptions.desc(e))
        except ldap.INVALID_CREDENTIALS, e:
            raise exceptions.InvalidAuth(exceptions.desc(e))
        except ldap.INSUFFICIENT_ACCESS, e:
            raise exceptions.InsufficientAccess(exceptions.desc(e))
        except ldap.OBJECT_CLASS_VIOLATION, e:
            raise exceptions.SchemaViolation(exceptions.desc(e))
        except ldap.NOT_ALLOWED_ON_NONLEAF, e:
            raise exceptions.DeleteOnParent(exceptions.desc(e))
        except ldap.NO_SUCH_OBJECT, e:
            raise exceptions.ObjectNotFound(exceptions.desc(e))
        except ldap.CONSTRAINT_VIOLATION, e:
            raise exceptions.ConstraintViolation(exceptions.desc(e))
    return handler