def authenticate(self, password):
user = None<EOL>try:<EOL><INDENT>self._authenticate_user_dn(password)<EOL>self._check_requirements()<EOL>self._get_or_create_user()<EOL>user = self._user<EOL><DEDENT>except self.AuthenticationFailed as e:<EOL><INDENT>logger.debug(u"<STR_LIT>" % (self._username, e))<EOL><DEDENT>except ldap.LDAPError as e:<EOL><INDENT>results = ldap_error.send(self.backend.__class__,<EOL>context='<STR_LIT>', exception=e)<EOL>if len(results) == <NUM_LIT:0>:<EOL><INDENT>logger.warning(u"<STR_LIT>",<EOL>self._username, pprint.pformat(e))<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>logger.exception(u"<STR_LIT>",<EOL>self._username)<EOL>raise<EOL><DEDENT>return user<EOL>
Authenticates against the LDAP directory and returns the corresponding
User object if successful. Returns None on failure.