def export(self, source=None):
        uidentities = {}
        uids = api.unique_identities(self.db, source=source)
        for uid in uids:
            enrollments = [rol.to_dict()
                           for rol in api.enrollments(self.db, uuid=uid.uuid)]
            u = uid.to_dict()
            u['identities'].sort(key=lambda x: x['id'])
            uidentities[uid.uuid] = u
            uidentities[uid.uuid]['enrollments'] = enrollments
        blacklist = [mb.excluded for mb in api.blacklist(self.db)]
        obj = {'time': str(datetime.datetime.now()),
               'source': source,
               'blacklist': blacklist,
               'organizations': {},
               'uidentities': uidentities}
        return json.dumps(obj, default=self._json_encoder,
                          indent=4, separators=(',', ': '),
                          sort_keys=True)