/** * Retrieves the entry with the specified DN using a read connection from this * connection pool. All user attributes will be requested in the entry to * return. * * @param dn The DN of the entry to retrieve. It must not be {@code null}. * * @return The requested entry, or {@code null} if the target entry does not * exist or no entry was returned (e.g., if the authenticated user * does not have permission to read the target entry). * * @throws LDAPException If a problem occurs while sending the request or * reading the response. */ public SearchResultEntry getEntry(final String dn) throws LDAPException { return readPool.getEntry(dn); }
/** * Retrieves the entry with the specified DN using a read connection from this * connection pool. * * @param dn The DN of the entry to retrieve. It must not be * {@code null}. * @param attributes The set of attributes to request for the target entry. * If it is {@code null}, then all user attributes will be * requested. * * @return The requested entry, or {@code null} if the target entry does not * exist or no entry was returned (e.g., if the authenticated user * does not have permission to read the target entry). * * @throws LDAPException If a problem occurs while sending the request or * reading the response. */ public SearchResultEntry getEntry(final String dn, final String... attributes) throws LDAPException { return readPool.getEntry(dn, attributes); }
/** * Checks if the configured directory base DN for the entries exists. * If not a WARN message is logged. */ private void checkBaseDN() { try { if (ldapConnPool.getEntry(config.ldapDirectory.baseDN.toString()) == null) { Loggers.MAIN_LOG.warn("[IL0101] The configured LDAP store base DN for {} cache doesn't exist: {}", cacheName, config.ldapDirectory.baseDN); } } catch (LDAPException e) { Loggers.MAIN_LOG.warn("[IL0102] Couldn't verify the LDAP store base DN for {} cache: {}", cacheName, e.getMessage()); } }
/** * Checks if the configured directory base DN for the entries exists. * If not a WARN message is logged. */ private void checkBaseDN() { try { if (ldapConnPool.getEntry(config.ldapDirectory.baseDN.toString()) == null) { Loggers.MAIN_LOG.warn("[IL0101] The configured LDAP store base DN for {} cache doesn't exist: {}", cacheName, config.ldapDirectory.baseDN); } } catch (LDAPException e) { Loggers.MAIN_LOG.warn("[IL0102] Couldn't verify the LDAP store base DN for {} cache: {}", cacheName, e.getMessage()); } }
@Override public Map<String, String> getAttributeValues(LDAPUserContext userContext, String... attributes) throws LDAPException { Map<String, String> result = new HashMap<String, String>(); List<String> retainedAttr = new ArrayList<String>(); Map<String, String> knownAttributes = ((DefaultLDAPUserContext) userContext).getKnownAttributes(); for (String attr : attributes) { if (knownAttributes.get(attr.toLowerCase()) == null) { retainedAttr.add(attr.toLowerCase()); } } if (!retainedAttr.isEmpty()) { LOGGER.debug("Will connect to LDAP to retrieve attributes {}", retainedAttr); try { SearchResultEntry entry = ldapConnectionPool.getEntry(userContext.getDn(), retainedAttr.toArray(new String[retainedAttr.size()])); for (String attr : retainedAttr) { knownAttributes.put(attr, entry.getAttributeValue(attr)); } } catch (com.unboundid.ldap.sdk.LDAPException e) { throw new LDAPException(e); } } for (String attr : attributes) { result.put(attr.toLowerCase(), knownAttributes.get(attr.toLowerCase())); } return result; }
/** * Retrieves the specified entry from the LDAP directory. * * @param dn The Distinguished Name (DN) of the entry to retrieve. Must * not be {@code null}. * * @return The matching directory entry, {@code null} if not found (or * insufficient privileges). */ public ReadOnlyEntry retrieveEntry(final DN dn) { Timer.Context timerCtx = ldapTimers.getTimer.time(); try { return ldapConnPool.getEntry(dn.toString(), SearchRequest.ALL_USER_ATTRIBUTES); } catch (LDAPException e) { throw new PersistenceException("LDAP get of " + dn + " failed: " + e.getResultString(), e); } finally { timerCtx.stop(); } }
/** * Checks that the specified entry exists in the LDAP directory. * * @param dn The Distinguished Name (DN) of the entry to check. Must * not be {@code null}. * * @return {@code true} if the entry exists, {@code false} if not * found (or insufficient privileges). */ public boolean entryExists(final DN dn) { Timer.Context timerCtx = ldapTimers.getTimer.time(); try { return ldapConnPool.getEntry(dn.toString(), SearchRequest.NO_ATTRIBUTES) != null; } catch (LDAPException e) { throw new PersistenceException("LDAP get of " + dn + " failed: " + e.getResultString(), e); } finally { timerCtx.stop(); } }
/** * Retrieves the specified entry from the LDAP directory. * * @param dn The Distinguished Name (DN) of the entry to retrieve. Must * not be {@code null}. * * @return The matching directory entry, {@code null} if not found (or * insufficient privileges). */ public ReadOnlyEntry retrieveEntry(final DN dn) { Timer.Context timerCtx = ldapTimers.getTimer.time(); try { return ldapConnPool.getEntry(dn.toString(), SearchRequest.ALL_USER_ATTRIBUTES); } catch (LDAPException e) { throw new PersistenceException("LDAP get of " + dn + " failed: " + e.getResultString(), e); } finally { timerCtx.stop(); } }
/** * Checks that the specified entry exists in the LDAP directory. * * @param dn The Distinguished Name (DN) of the entry to check. Must * not be {@code null}. * * @return {@code true} if the entry exists, {@code false} if not * found (or insufficient privileges). */ public boolean entryExists(final DN dn) { Timer.Context timerCtx = ldapTimers.getTimer.time(); try { return ldapConnPool.getEntry(dn.toString(), SearchRequest.NO_ATTRIBUTES) != null; } catch (LDAPException e) { throw new PersistenceException("LDAP get of " + dn + " failed: " + e.getResultString(), e); } finally { timerCtx.stop(); } }
getReferencedEntriesPool.getEntry(value, "1.1"); if (e == null)