<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_results(self, results):
 """ Format the ldap results object into somthing that is reasonable """

        if not results:
            return None
        userdn = results[0][0]
        userobj = results[0][1]
        userobj['dn'] = userdn

        keymap = self.config.get('KEY_MAP')
        if keymap:
            return {key:scalar(userobj.get(value)) for key, value in keymap.items() if _is_utf8(scalar(userobj.get(value))) }
        else:
            return {key:scalar(value) for key, value in userobj.items() if _is_utf8(scalar(value)) }