'Find a set of NameID\'s that matches the search criteria.
:param userid: User id
:param kwargs: The search filter a set of attribute/value pairs
:return: a list of NameID instances'

def find_nameid(self, userid, **kwargs):

    res = []
    try:
        _vals = self.db[userid]
    except KeyError:
        logger.debug(('failed    to    find    userid    %s    in    IdentDB' % userid))
        return res
    for val in _vals.split('    '):
        nid = decode(val)
        if kwargs:
            for (key, _val) in kwargs.items():
                if (getattr(nid, key, None) != _val):
                    break
            else:
                res.append(nid)
        else:
            res.append(nid)
    return res
