use of password.pwm.http.bean.ConfigManagerBean in project pwm by pwm-project.
the class ConfigEditorServlet method restBrowseLdap.
@ActionHandler(action = "browseLdap")
private ProcessStatus restBrowseLdap(final PwmRequest pwmRequest) throws IOException, ServletException, PwmUnrecoverableException {
final Instant startTime = Instant.now();
final ConfigManagerBean configManagerBean = getBean(pwmRequest);
final Map<String, String> inputMap = pwmRequest.readBodyAsJsonStringMap(PwmHttpRequestWrapper.Flag.BypassValidation);
final String profile = inputMap.get("profile");
final String dn = inputMap.containsKey("dn") ? inputMap.get("dn") : "";
final LdapBrowser ldapBrowser = new LdapBrowser(pwmRequest.getPwmApplication().getLdapConnectionService().getChaiProviderFactory(), configManagerBean.getStoredConfiguration());
LdapBrowser.LdapBrowseResult result;
try {
result = ldapBrowser.doBrowse(profile, dn);
} catch (PwmUnrecoverableException e) {
// Probably was given a bad dn, better just browse without a DN than error out completely
result = ldapBrowser.doBrowse(profile, "");
}
ldapBrowser.close();
LOGGER.trace(pwmRequest, "performed ldapBrowse operation in " + TimeDuration.fromCurrent(startTime).asCompactString() + ", result=" + JsonUtil.serialize(result));
pwmRequest.outputJsonResult(RestResultBean.withData(result));
return ProcessStatus.Halt;
}
Aggregations