code: def authenticate(self, password):
          
          user = None
  
          try:
              self._authenticate_user_dn(password)
              self._check_requirements()
              self._get_or_create_user()
  
              user = self._user
          except self.AuthenticationFailed as e:
              logger.debug(u"Authentication failed for %s: %s" % (self._username, e))
          except ldap.LDAPError as e:
              results = ldap_error.send(self.backend.__class__,
                                        context='authenticate', exception=e)
              if len(results) == 0:
                  logger.warning(u"Caught LDAPError while authenticating %s: %s",
                                 self._username, pprint.pformat(e))
          except Exception:
              logger.exception(u"Caught Exception while authenticating %s",
                               self._username)
              raise
  
          return user
docs: Authenticates against the LDAP directory and returns the corresponding
          User object if successful. Returns None on failure.