log.info("Server: " + baseURI);
log.info("filter: " + queryString);
log.info("get attributes: " + join(toGet, ","));
DirContext context = new InitialDirContext();
NamingEnumeration<SearchResult> results = null;
if ("".equals(queryString)) // We aren't searching, just get attributes
{
Attributes attrs = context.getAttributes(baseURI, (String[]) toGet
.toArray(new String[] {}));
// Wrap this to fit this method's contract
SearchResult sr = new SearchResult(null, null, attrs);
sr.setNameInNamespace(uriToName(baseURI));
results = new SingletonNamingEnumeration<SearchResult>(sr);
}
else // An actual query
{
SearchControls sc = new SearchControls();
sc.setReturningAttributes(toGet.toArray(new String[] {}));
sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
results = context.search(baseURI, queryString, sc);
}
return results;
}