SearchResult
NaminEnumeration
This class is not thread-safe.
289290291292293294295296297298299
// The search has been executed, so process up to one batch of // results. List<?> result = null; while (result == null && searchEnumeration != null && searchEnumeration.hasMore()) { SearchResult searchResult = (SearchResult) searchEnumeration.next(); result = getRow(searchResult); } return result; } catch (SizeLimitExceededException e) {
207208209210211212213214215216217218219220221222223224225226227228229
doc.getDocumentElement().appendChild(resultElement); Element record = null; Element attribute = null; SearchResult sr = null; NamingEnumeration attrs = null; Attribute attr = null; String key = null; NamingEnumeration values = null; String value = null; try { while (results.hasMore()) { sr = (SearchResult) results.next(); attrs = sr.getAttributes().getAll(); record = doc.createElement("Record"); while (attrs.hasMore()) {
132133134135136137138139140141142143144145146147148149
{ ldapResult = executeLdap(binding, context); while (ldapResult.hasMore()) { SearchResult sr = ldapResult.next(); Attributes sra = sr.getAttributes(); Map<String, Node> aBinding = new HashMap<String, Node>(); // Mapping results to rdf if (subject.isVariable()) aBinding.put(subject.getName(), createLdapNode(sr .getNameInNamespace())); boolean valid = true; for (Triple triple : query)
319320321322323324325326327328329330
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();
858687888990919293949596
assertTrue("I found Paul", results.hasMore()); while (results.hasMore()) { SearchResult result = results.next(); Attributes attributes = result.getAttributes(); NamingEnumeration<? extends Attribute> theAttributes = attributes.getAll(); while (theAttributes.hasMore()) { Attribute attribute = theAttributes.next(); log.info("Attribute: " + attribute.getID());
130131132133134135136137138139140141142143144
NamingEnumeration<SearchResult> results = map.executeLdap(new BindingRoot(), null); assertTrue("I got a result", results.hasMore()); SearchResult result = results.next(); log.info("Result: " + result.getNameInNamespace()); assertEquals("Paul's email address is right", "paul.shabajee@hp.com", result.getAttributes().get("uid").get(0)); results.close(); Iterator<Map <String, Node>> res = map.execute(new BindingRoot(), null);
161162163164165166167168169170171172
} } private void mapResults(PagedResultMapper mapper, NamingEnumeration<SearchResult> results) throws NamingException { while (results != null && results.hasMore()) { SearchResult searchResult = results.next(); String dn = searchResult.getNameInNamespace(); try { if (isDnValid(dn)) { if (logger.isDebugEnabled()) { logger.debug("Included result " + dn);
545556575859606162636465
try { SearchControls sctrl = new SearchControls(); String filter = "(&(objectclass=organizationalUnit)(ou=*))"; NamingEnumeration enm = ctx.search(baseDN, filter, sctrl); while (enm.hasMore()) { SearchResult sr = (SearchResult) enm.next(); config.setCategory(sr.getName()); } } catch (Exception e) { ErrorReporter.getErrorHandler().reportError(e.getLocalizedMessage(), e); }
156157158159160161162163164165166167
String userDN = null; for (String ldapBase : ldapBases) { try { NamingEnumeration<SearchResult> enm = ctx.search(ldapBase, filter, ctls); while (enm.hasMore()) { SearchResult result = enm.next(); userDN = result.getNameInNamespace(); } if (userDN != null) break; } catch (NamingException e) { log.error("NamingException when trying to bind user with username::" + uid + " on ldapBase::" + ldapBase, e); }
262263264265266267268269270271272273
String userDN = null; for (String ldapBase : ldapBases) { try { NamingEnumeration<SearchResult> enm = ctx.search(ldapBase, filter, ctls); while (enm.hasMore()) { SearchResult result = enm.next(); userDN = result.getNameInNamespace(); } if (userDN != null) { break; } } catch (NamingException e) {