def METHOD_NAME(self, username, password, retry=True, fields=None):
    # fields can be used in local implementation to retrieve user information from
    # ldap.  In ALBA for example, it is used to obtain homeDirectory upon successful
    # login and use that value for programming session hwo directories
    self.field_values = None
    if self.ldapConnection is None:
        return self.cleanup(msg="no LDAP server configured")
    logging.getLogger("HWR").debug(
        "LdapLogin: searching for %s / %s" % (username, self.domstr)
    )
    try:
        search_str = self.domstr
        if fields is None:
            found = self.ldapConnection.search_s(
                search_str, ldap.SCOPE_SUBTREE, "uid=" + username, ["uid"]
            )
        else:
            found = self.ldapConnection.search_s(
                search_str, ldap.SCOPE_SUBTREE, "uid=" + username, fields
            )
    except ldap.LDAPError as err:
        if retry:
            self.cleanup(ex=err)
            return self.METHOD_NAME(username, password, retry=False)
        else:
            return self.cleanup(ex=err)
    if not found:
        return self.cleanup(msg="unknown proposal %s" % username)
    if fields is not None:
        self.field_values = found[0][1]
    if password == "":
        return self.cleanup(msg="invalid password for %s" % username)
    logging.getLogger("HWR").debug("LdapLogin: validating %s" % username)
    try:
        bind_str = "uid=%s, ou=%s, %s" % (username, self.ldapou, self.domstr)
    except AttributeError as attr:
        bind_str = "uid=%s,%s" % (username, self.domstr)
    logging.getLogger("HWR").debug("LdapLogin: binding to %s" % bind_str)
    handle = self.ldapConnection.simple_bind(bind_str, password)
    try:
        result = self.ldapConnection.result(handle)
    except ldap.INVALID_CREDENTIALS:
        # try second time with different bind_str
        bind_str = "uid=%s, ou=people,%s" % (username, self.domstr)
        handle = self.ldapConnection.simple_bind(bind_str, password)
        try:
            result = self.ldapConnection.result(handle)
        except Exception:
            return self.cleanup(msg="invalid password for %s" % username)
    except ldap.LDAPError as err:
        if retry:
            self.cleanup(ex=err)
            return self.METHOD_NAME(username, password, retry=False)
        else:
            return self.cleanup(ex=err)
    return (True, username)