def parse_group_names(group_results, name_attr):
    """
    Parses results from LDAP group search into a list of group names.
    """
    groups = []
    for distinguished_name, entry in group_results:
        if distinguished_name is not None and name_attr in entry:
            group_name = entry[name_attr]
            if group_name:
                groups.append(group_name[0].decode('utf-8', errors='replace'))

    return groups