List<String> getRoles() throws LDAPException { final SearchRequest searchRequest = new SearchRequest( roleBaseDN, ONE, "(uniqueMember=" + userDN + ")", CN); final SearchResult searchResult = ldapInterface.search(searchRequest); return searchResult.getSearchEntries() .stream() .flatMap(entry -> stream(entry.getAttributeValues("CN"))) .collect(toList()); }
/** * Indicates whether the specified entry exists in the server. * * @param conn The connection to use to communicate with the directory * server. * @param dn The DN of the entry for which to make the determination. * * @return {@code true} if the entry exists, or {@code false} if not. * * @throws LDAPException If a problem is encountered while trying to * communicate with the directory server. */ public static boolean entryExists(final LDAPInterface conn, final String dn) throws LDAPException { return (conn.getEntry(dn, "1.1") != null); }
/** * {@inheritDoc} */ @Override() public LDAPResult processChange(final LDAPInterface connection, final boolean includeControls) throws LDAPException { return connection.add(toAddRequest(includeControls)); }
/** * {@inheritDoc} */ @Override() public LDAPResult processChange(final LDAPInterface connection, final boolean includeControls) throws LDAPException { return connection.modify(toModifyRequest(includeControls)); }
/** * {@inheritDoc} */ @Override() public LDAPResult processChange(final LDAPInterface connection, final boolean includeControls) throws LDAPException { return connection.delete(toDeleteRequest(includeControls)); }
/** * {@inheritDoc} */ @Override() public LDAPResult processChange(final LDAPInterface connection, final boolean includeControls) throws LDAPException { return connection.modifyDN(toModifyDNRequest(includeControls)); }
/** * {@inheritDoc} */ @Override() public LDAPResult processChange(final LDAPInterface connection, final boolean includeControls) throws LDAPException { return connection.add(toAddRequest(includeControls)); }
/** * {@inheritDoc} */ @Override() public LDAPResult processChange(final LDAPInterface connection, final boolean includeControls) throws LDAPException { return connection.modify(toModifyRequest(includeControls)); }
/** * {@inheritDoc} */ @Override() public LDAPResult processChange(final LDAPInterface connection, final boolean includeControls) throws LDAPException { return connection.delete(toDeleteRequest(includeControls)); }
/** * {@inheritDoc} */ @Override() public LDAPResult processChange(final LDAPInterface connection, final boolean includeControls) throws LDAPException { return connection.modifyDN(toModifyDNRequest(includeControls)); }
/** * Retrieves the FIFO entry cache monitor entries from the Directory Server. * * @param connection The connection to use to communicate with the Directory * Server. * * @return The entry cache monitor entry from the Directory Server, or * {@code null} if it is not available. * * @throws LDAPSearchException If a problem occurs while communicating with * the Directory Server. */ public static List<FIFOEntryCacheMonitorEntry> getFIFOEntryCacheMonitorEntries(final LDAPInterface connection) throws LDAPSearchException { final Filter filter = Filter.createEqualityFilter("objectClass", FIFOEntryCacheMonitorEntry.FIFO_ENTRY_CACHE_MONITOR_OC); final SearchResult searchResult = connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter); final ArrayList<FIFOEntryCacheMonitorEntry> monitorEntries = new ArrayList<FIFOEntryCacheMonitorEntry>( searchResult.getEntryCount()); for (final SearchResultEntry e : searchResult.getSearchEntries()) { monitorEntries.add(new FIFOEntryCacheMonitorEntry(e)); } return Collections.unmodifiableList(monitorEntries); }
/** * Retrieves a list containing the DNs of the entries which are missing from * the directory server. * * @param conn The connection to use to communicate with the directory * server. * @param dns The DNs of the entries to try to find in the server. * * @return A list containing all of the provided DNs that were not found in * the server, or an empty list if all entries were found. * * @throws LDAPException If a problem is encountered while trying to * communicate with the directory server. */ public static List<String> getMissingEntryDNs(final LDAPInterface conn, final Collection<String> dns) throws LDAPException { final List<String> missingDNs = new ArrayList<String>(dns.size()); for (final String dn : dns) { if (conn.getEntry(dn, "1.1") == null) { missingDNs.add(dn); } } return missingDNs; }
return i.add(addRequest);
return i.modify(modifyRequest);
return i.delete(deleteRequest);
connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter);
/** * Ensures that the specified entry does not exist in the directory. * * @param conn The connection to use to communicate with the directory * server. * @param dn The DN of the entry expected to be missing. * * @throws LDAPException If a problem is encountered while trying to * communicate with the directory server. * * @throws AssertionError If the target entry is found in the server. */ public static void assertEntryMissing(final LDAPInterface conn, final String dn) throws LDAPException, AssertionError { if (conn.getEntry(dn, "1.1") != null) { throw new AssertionError(ERR_TEST_ENTRY_EXISTS.get(dn)); } }
connection.search(MonitorEntry.MONITOR_BASE_DN, SearchScope.SUB, filter);