コード例 #1
0
    def error_handling(self, etype, exc, etraceback):
        """
		Translate generic UDM exceptions back to LDAP exceptions.

		:param etype: The exception class.
		:param exc: The exception instance.
		:param etraceback: The exception traceback instance; may be None.
		"""
        if (isinstance(exc, udm_errors.ldapError)
                and isinstance(getattr(exc, 'original_exception', None),
                               ldap.LDAPError)) or isinstance(
                                   exc, ldap.LDAPError):
            #  After an exception the ReconnectLDAPObject instance can be in a state without a bind. Which can result
            #  in a "ldapError: Insufficient access" exception, because the connection is anonymous. Prevent the usage
            #  of a ReconnectLDAPObject instance after an exception by clearing the connection cache.
            #  Bug #46089
            reset_ldap_connection_cache()
        if isinstance(exc, udm_errors.ldapError) and isinstance(
                getattr(exc, 'original_exception', None), ldap.SERVER_DOWN):
            exc = exc.original_exception
        if isinstance(exc, udm_errors.ldapError) and isinstance(
                getattr(exc, 'original_exception', None),
                ldap.INVALID_CREDENTIALS):
            exc = exc.original_exception
        if isinstance(exc, ldap.SERVER_DOWN):
            raise LDAP_ServerDown()
        if isinstance(exc, ldap.CONNECT_ERROR):
            raise LDAP_ConnectionFailed(exc)
        if isinstance(exc, ldap.INVALID_CREDENTIALS):
            #  Ensure the connection cache is empty to prevent the use of expired saml messages
            #  Bug #44621
            reset_ldap_connection_cache()
            raise Unauthorized
コード例 #2
0
 def error_handling(self, etype, exc, etraceback):
     if isinstance(exc, udm_errors.ldapError) and isinstance(
             getattr(exc, 'original_exception', None), ldap.SERVER_DOWN):
         exc = exc.original_exception
     if isinstance(exc, udm_errors.ldapError) and isinstance(
             getattr(exc, 'original_exception', None),
             ldap.INVALID_CREDENTIALS):
         exc = exc.original_exception
     if isinstance(exc, ldap.SERVER_DOWN):
         raise LDAP_ServerDown()
     if isinstance(exc, ldap.CONNECT_ERROR):
         raise LDAP_ConnectionFailed(exc)
     if isinstance(exc, ldap.INVALID_CREDENTIALS):
         reset_ldap_connection_cache()
         raise Unauthorized
コード例 #3
0
	def error_handling(self, etype, exc, etraceback):
		"""
		Translate generic UDM exceptions back to LDAP exceptions.

		:param etype: The exception class.
		:param exc: The exception instance.
		:param etraceback: The exception traceback instance; may be None.
		"""
		if isinstance(exc, udm_errors.ldapError) and isinstance(getattr(exc, 'original_exception', None), ldap.SERVER_DOWN):
			exc = exc.original_exception
		if isinstance(exc, udm_errors.ldapError) and isinstance(getattr(exc, 'original_exception', None), ldap.INVALID_CREDENTIALS):
			exc = exc.original_exception
		if isinstance(exc, ldap.SERVER_DOWN):
			raise LDAP_ServerDown()
		if isinstance(exc, ldap.CONNECT_ERROR):
			raise LDAP_ConnectionFailed(exc)
		if isinstance(exc, ldap.INVALID_CREDENTIALS):
			reset_ldap_connection_cache()
			raise Unauthorized