def ping(self, raise_exception=False):
    tries_count = 3
    for _ in range(tries_count):
        try:
            self.client.search_s(self.user_base_dn, ldap.SCOPE_SUBTREE)
        except ldap.LDAPError as e:
            if raise_exception:
                six.reraise(LDAPBackendError, e)
        else:
            return True
    return False
def ping(self, raise_exception=False):
    tries_count = 3
    for _ in range(tries_count):
        try:
            self.client.search_s(self.user_base_dn, ldap.SCOPE_SUBTREE)
        except ldap.LDAPError as e:
            if raise_exception:
                six.reraise(LDAPBackendError, e)
        else:
            return True
    return False