Search in sources :

Example 1 with EntryNotFoundException

use of org.forgerock.opendj.ldap.EntryNotFoundException in project OpenAM by OpenRock.

the class SMSLdapObject method entryExists.

/**
     * Checks if the provided DN exists.
     */
private static boolean entryExists(String dn) throws SMSException {
    boolean entryExists = false;
    try (Connection conn = getConnection(adminPrincipal)) {
        // Use the Admin Principal to check if entry exists
        conn.searchSingleEntry(LDAPRequests.newSingleEntrySearchRequest(dn, OU_ATTR));
        entryExists = true;
    } catch (EntryNotFoundException e) {
        debug.warning("SMSLdapObject:entryExists: {} does not exist", dn);
    } catch (LdapException e) {
        throw new SMSException("Unable to find entry with DN: " + dn, e, IUMSConstants.SMS_LDAP_OPERATION_FAILED);
    }
    return entryExists;
}
Also used : SMSException(com.sun.identity.sm.SMSException) Connection(org.forgerock.opendj.ldap.Connection) EntryNotFoundException(org.forgerock.opendj.ldap.EntryNotFoundException) LdapException(org.forgerock.opendj.ldap.LdapException)

Aggregations

SMSException (com.sun.identity.sm.SMSException)1 Connection (org.forgerock.opendj.ldap.Connection)1 EntryNotFoundException (org.forgerock.opendj.ldap.EntryNotFoundException)1 LdapException (org.forgerock.opendj.ldap.LdapException)1