'Return a filtered list of groups for which the user is a member.'

def list_user_groups_filtered(self, user_dn, hints):

    user_dn_esc = ldap.filter.escape_filter_chars(user_dn)
    if self.group_ad_nesting:
        query = ('(member:%s:=%s)' % (LDAP_MATCHING_RULE_IN_CHAIN, user_dn_esc))
    else:
        query = ('(%s=%s)' % (self.member_attribute, user_dn_esc))
    return self.get_all_filtered(hints, query)
