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;
}
Aggregations