if (null == subschemasubentry) {
filterParser = new FilterParser("(objectClass=*)");
try {
filter = filterParser.parse();
} catch (ParseException e) {
InvalidSearchFilterException ex = new InvalidSearchFilterException(
Messages.getString("ldap.29")); //$NON-NLS-1$
ex.setRootCause(e);
throw ex;
}
searchControls.setSearchScope(SearchControls.OBJECT_SCOPE);
searchControls.setReturningAttributes(new String[] {
"namingContexts", "subschemaSubentry", "altServer", });
search = new SearchOp("", searchControls, filter);
try {
client.doOperation(search, requestControls);
} catch (IOException e) {
CommunicationException ex = new CommunicationException(e
.getMessage());
ex.setRootCause(e);
if (search.getSearchResult().isEmpty()) {
throw ex;
}
search.getSearchResult().setException(ex);
}
sre = search.getSearchResult();
names = sre.getEntries();
keyset = names.keySet();
schemaRoot: for (Iterator<String> iterator = keyset.iterator(); iterator
.hasNext();) {
String key = iterator.next();
Attributes as = names.get(key);
NamingEnumeration<String> ids = as.getIDs();
while (ids.hasMore()) {
String id = ids.next();
if (id.equalsIgnoreCase("subschemasubentry")) {
subschemasubentry = (String) as.get(id).get();
break schemaRoot;
}
}
}
}
searchControls.setSearchScope(SearchControls.OBJECT_SCOPE);
searchControls.setReturningAttributes(new String[] { "objectclasses",
"attributetypes", "matchingrules", "ldapsyntaxes" });
searchControls.setReturningObjFlag(true);
filterParser = new FilterParser("(objectClass=subschema)");
try {
filter = filterParser.parse();
} catch (ParseException e) {
InvalidSearchFilterException ex = new InvalidSearchFilterException(
Messages.getString("ldap.29")); //$NON-NLS-1$
ex.setRootCause(e);
throw ex;
}
search = new SearchOp(subschemasubentry, searchControls, filter);
try {
client.doOperation(search, requestControls);
} catch (IOException e) {
CommunicationException ex = new CommunicationException(e
.getMessage());
ex.setRootCause(e);
if (search.getSearchResult().isEmpty()) {
throw ex;
}
search.getSearchResult().setException(ex);
}