private void loadRoles(String filter, InitialLdapContext context, boolean removeMissingEntries) throws Exception {
final Collection<String> groupNames = groupContainer.retrievePrincipalNames();
PagedResultMapper mapper = new AbstractPagedResultMapper() {
public void mapSearchResult(SearchResult searchResult) throws NamingException {
String dn = searchResult.getNameInNamespace();
Attributes attributes = searchResult.getAttributes();
String commonName = getAttributeValue(attributes, COMMON_NAME_ATTRIBUTE);
if (commonName.length() != 0) {
Long rid = ActiveDirectoryGroup.getRIDFromSID((byte[]) attributes.get(OBJECT_SID_ATTRIBUTE).get());
ActiveDirectoryGroup group = new ActiveDirectoryGroup(commonName, dn, getEscapedDn(dn), rid, getRealm());
String[] parents = getParents(attributes);
String key = groupContainer.storeGroup(group, parents);
groupNames.remove(key);
}