/** @inheritDoc */
  public List getUnassignedMembersInRole(final String siteContext, final Role role) {
    List siteMembers = getSiteMembersInRole(siteContext, role);

    // Get all userUids of all users in sections
    List<String> sectionedUserUids = new ArrayList<String>();
    List sections = getSections(siteContext);
    for (Iterator sectionIter = sections.iterator(); sectionIter.hasNext(); ) {
      CourseSection section = (CourseSection) sectionIter.next();
      List sectionUsers = securityService.unlockUsers(getLock(role), section.getUuid());
      for (Iterator userIter = sectionUsers.iterator(); userIter.hasNext(); ) {
        org.sakaiproject.user.api.User user = (org.sakaiproject.user.api.User) userIter.next();
        sectionedUserUids.add(user.getId());
      }
    }

    // Now generate the list of unsectioned enrollments by subtracting the two collections
    // Since the APIs return different kinds of objects, we need to iterate
    List<ParticipationRecord> unsectionedMembers = new ArrayList<ParticipationRecord>();
    for (Iterator iter = siteMembers.iterator(); iter.hasNext(); ) {
      ParticipationRecord record = (ParticipationRecord) iter.next();
      if (!sectionedUserUids.contains(record.getUser().getUserUid())) {
        unsectionedMembers.add(record);
      }
    }
    return unsectionedMembers;
  }
 /** @inheritDoc */
 public List findSiteMembersInRole(
     final String siteContext, final Role role, final String pattern) {
   List fullList = getSiteMembersInRole(siteContext, role);
   List<ParticipationRecord> filteredList = new ArrayList<ParticipationRecord>();
   for (Iterator iter = fullList.iterator(); iter.hasNext(); ) {
     ParticipationRecord record = (ParticipationRecord) iter.next();
     User user = record.getUser();
     if (user.getDisplayName().toLowerCase().startsWith(pattern.toLowerCase())
         || user.getSortName().toLowerCase().startsWith(pattern.toLowerCase())
         || user.getDisplayId().toLowerCase().startsWith(pattern.toLowerCase())) {
       filteredList.add(record);
     }
   }
   return filteredList;
 }