Search in sources :

Example 21 with ConfigManagerBean

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;
}
Also used : ConfigManagerBean(password.pwm.http.bean.ConfigManagerBean) Instant(java.time.Instant) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) LdapBrowser(password.pwm.ldap.LdapBrowser)

Aggregations

ConfigManagerBean (password.pwm.http.bean.ConfigManagerBean)21 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)10 PwmException (password.pwm.error.PwmException)9 RestResultBean (password.pwm.ws.server.RestResultBean)9 PwmSetting (password.pwm.config.PwmSetting)7 StoredConfigurationImpl (password.pwm.config.stored.StoredConfigurationImpl)7 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)6 IOException (java.io.IOException)6 Instant (java.time.Instant)6 LinkedHashMap (java.util.LinkedHashMap)6 ServletException (javax.servlet.ServletException)6 ErrorInformation (password.pwm.error.ErrorInformation)6 PwmOperationalException (password.pwm.error.PwmOperationalException)6 Configuration (password.pwm.config.Configuration)5 PwmLocaleBundle (password.pwm.i18n.PwmLocaleBundle)5 HealthData (password.pwm.ws.server.rest.bean.HealthData)5 StringTokenizer (java.util.StringTokenizer)4 UserIdentity (password.pwm.bean.UserIdentity)4 HealthRecord (password.pwm.health.HealthRecord)4 ArrayList (java.util.ArrayList)3