Search in sources :

Example 21 with SearchResultReferenceIOException

use of org.forgerock.opendj.ldap.SearchResultReferenceIOException in project admin-console-beta by connexta.

the class ServerGuesser method getBaseContexts.

public List<String> getBaseContexts() {
    try {
        ConnectionEntryReader reader = connection.search("", SearchScope.BASE_OBJECT, "(objectClass=*)", "namingContexts");
        ArrayList<String> contexts = new ArrayList<>();
        while (reader.hasNext()) {
            SearchResultEntry entry = reader.readEntry();
            if (entry.containsAttribute("namingContexts")) {
                contexts.add(entry.getAttribute("namingContexts").firstValueAsString());
            }
        }
        if (contexts.isEmpty()) {
            contexts.add("");
        }
        return contexts;
    } catch (LdapException | SearchResultReferenceIOException e) {
        LOGGER.debug("Error getting baseContext", e);
        return Collections.singletonList("");
    }
}
Also used : ConnectionEntryReader(org.forgerock.opendj.ldif.ConnectionEntryReader) ArrayList(java.util.ArrayList) SearchResultReferenceIOException(org.forgerock.opendj.ldap.SearchResultReferenceIOException) LdapException(org.forgerock.opendj.ldap.LdapException) SearchResultEntry(org.forgerock.opendj.ldap.responses.SearchResultEntry)

Aggregations

LdapException (org.forgerock.opendj.ldap.LdapException)21 SearchResultReferenceIOException (org.forgerock.opendj.ldap.SearchResultReferenceIOException)21 SearchResultEntry (org.forgerock.opendj.ldap.responses.SearchResultEntry)18 ConnectionEntryReader (org.forgerock.opendj.ldif.ConnectionEntryReader)18 Connection (org.forgerock.opendj.ldap.Connection)16 ByteString (org.forgerock.opendj.ldap.ByteString)14 HashSet (java.util.HashSet)10 SearchRequest (org.forgerock.opendj.ldap.requests.SearchRequest)9 LinkedHashSet (java.util.LinkedHashSet)8 Attribute (org.forgerock.opendj.ldap.Attribute)8 ResultCode (org.forgerock.opendj.ldap.ResultCode)7 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)5 Filter (org.forgerock.opendj.ldap.Filter)5 PolicyException (com.sun.identity.policy.PolicyException)4 DN (org.forgerock.opendj.ldap.DN)4 LinkedAttribute (org.forgerock.opendj.ldap.LinkedAttribute)4 SSOException (com.iplanet.sso.SSOException)2 InvalidNameException (com.sun.identity.policy.InvalidNameException)2 NameNotFoundException (com.sun.identity.policy.NameNotFoundException)2 ValidValues (com.sun.identity.policy.ValidValues)2