Search in sources :

Example 1 with InvalidSearchFilterException

use of com.iplanet.ums.InvalidSearchFilterException in project OpenAM by OpenRock.

the class DirectoryServicesImpl method verifyAndGetOrgDN.

/**
     * Gets the Organization DN for the specified entryDN. If the entry itself
     * is an org, then same DN is returned.
     * 
     * @param token
     *            a valid SSOToken
     * @param entryDN
     *            the entry whose parent Organization is to be obtained
     * @param childDN
     *            the immediate entry whose parent Organization is to be
     *            obtained
     * @return the DN String of the parent Organization
     * @throws AMException
     *             if an error occured while obtaining the parent Organization
     */
public String verifyAndGetOrgDN(SSOToken token, String entryDN, String childDN) throws AMException {
    if (entryDN.isEmpty() || DN.valueOf(entryDN).size() <= 0) {
        debug.error("DirectoryServicesImpl.verifyAndGetOrgDN() Invalid " + "DN: " + entryDN);
        throw new AMException(token, "157");
    }
    String organizationDN = null;
    boolean errorCondition = false;
    try {
        PersistentObject po = UMSObject.getObjectHandle(internalToken, new Guid(childDN));
        String searchFilter = getOrgSearchFilter(entryDN);
        SearchResults result = po.search(searchFilter, aName, scontrol);
        if (result.hasMoreElements()) {
            // ABANDON logged in directory server access logs.
            while (result.hasMoreElements()) {
                result.next();
            }
            organizationDN = po.getGuid().toString().toLowerCase();
        }
    } catch (InvalidSearchFilterException e) {
        errorCondition = true;
        debug.error("DirectoryServicesImpl.verifyAndGetOrgDN(): Invalid " + "search filter, unable to get Parent Organization: ", e);
    } catch (UMSException ue) {
        errorCondition = true;
        if (debug.warningEnabled()) {
            debug.warning("DirectoryServicesImpl.verifyAndGetOrgDN(): " + "Unable to Obtain Parent Organization", ue);
        }
        LdapException lex = (LdapException) ue.getRootCause();
        ResultCode errorCode = lex.getResult().getResultCode();
        if (retryErrorCodes.contains("" + errorCode)) {
            throw new AMException(token, Integer.toString(errorCode.intValue()), ue);
        }
    }
    if (errorCondition) {
        String locale = CommonUtils.getUserLocale(token);
        throw new AMException(AMSDKBundle.getString("124", locale), "124");
    }
    return organizationDN;
}
Also used : UMSException(com.iplanet.ums.UMSException) InvalidSearchFilterException(com.iplanet.ums.InvalidSearchFilterException) AMException(com.iplanet.am.sdk.AMException) PersistentObject(com.iplanet.ums.PersistentObject) Guid(com.iplanet.ums.Guid) AMSearchResults(com.iplanet.am.sdk.AMSearchResults) SearchResults(com.iplanet.ums.SearchResults) LdapException(org.forgerock.opendj.ldap.LdapException) ResultCode(org.forgerock.opendj.ldap.ResultCode)

Aggregations

AMException (com.iplanet.am.sdk.AMException)1 AMSearchResults (com.iplanet.am.sdk.AMSearchResults)1 Guid (com.iplanet.ums.Guid)1 InvalidSearchFilterException (com.iplanet.ums.InvalidSearchFilterException)1 PersistentObject (com.iplanet.ums.PersistentObject)1 SearchResults (com.iplanet.ums.SearchResults)1 UMSException (com.iplanet.ums.UMSException)1 LdapException (org.forgerock.opendj.ldap.LdapException)1 ResultCode (org.forgerock.opendj.ldap.ResultCode)1