use of password.pwm.ldap.LdapBrowser in project pwm by pwm-project.
the class ConfigGuideServlet method restBrowseLdap.
@ActionHandler(action = "browseLdap")
private ProcessStatus restBrowseLdap(final PwmRequest pwmRequest) throws IOException, PwmUnrecoverableException {
final ConfigGuideBean configGuideBean = getBean(pwmRequest);
final StoredConfigurationImpl storedConfiguration = ConfigGuideForm.generateStoredConfig(configGuideBean);
if (configGuideBean.getStep() == GuideStep.LDAP_PROXY) {
storedConfiguration.resetSetting(PwmSetting.LDAP_PROXY_USER_DN, LDAP_PROFILE_KEY, null);
storedConfiguration.resetSetting(PwmSetting.LDAP_PROXY_USER_PASSWORD, LDAP_PROFILE_KEY, null);
}
final Instant startTime = Instant.now();
final Map<String, String> inputMap = pwmRequest.readBodyAsJsonStringMap(PwmHttpRequestWrapper.Flag.BypassValidation);
final String profile = inputMap.get("profile");
final String dn = inputMap.getOrDefault("dn", "");
final LdapBrowser ldapBrowser = new LdapBrowser(pwmRequest.getPwmApplication().getLdapConnectionService().getChaiProviderFactory(), storedConfiguration);
final LdapBrowser.LdapBrowseResult result = ldapBrowser.doBrowse(profile, dn);
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;
}
use of password.pwm.ldap.LdapBrowser 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