@Override protected Object doMapFromContext(DirContextOperations ctx) { if (resultFilter != null && !resultFilter.needSelect(ctx.getNameInNamespace())){ return null; } Map<String, Object> result = new HashMap<>(); result.put(LdapConstant.LDAP_DN_KEY, ctx.getNameInNamespace()); List<Object> list = new ArrayList<>(); result.put("attributes", list); Attributes attributes = ctx.getAttributes(); NamingEnumeration it = attributes.getAll(); try { while (it.hasMore()){ list.add(it.next()); } } catch (javax.naming.NamingException e){ logger.error("query ldap entry attributes fail", e.getCause()); throw new OperationFailureException(operr("query ldap entry fail, %s", e.toString())); } return result; } }, processor);
public Throwable getCause(Throwable t) { return (t instanceof NamingException ? ((NamingException) t).getCause() : null); }
private Object lookupJNDIWithRetry(String jndiName, int attempt) { try { return context.lookup(jndiName); } catch (NamingException ex) { if (ex.getCause() instanceof IllegalStateException && attempt < 100) { //TODO: do this a better way //the destination isn't yet available try { Thread.sleep(10); } catch (InterruptedException ignored) {} return lookupJNDIWithRetry(jndiName, attempt + 1); } return null; } }
public Object nextElement() { try { return next(); } catch ( NamingException e ) { e.printStackTrace(); throw new NoSuchElementException( "Got IO Failure on btree: " + e.getCause().getMessage() ); } } }
public Object nextElement() { try { return next(); } catch ( NamingException e ) { e.printStackTrace(); throw new NoSuchElementException( "Got IO Failure on btree: " + e.getCause().getMessage() ); } } }
@Override public void stopConnection() { uptime = 1; if(dctx != null) try { dctx.close(); } catch (NamingException e) { log(Level.ERROR, e, "Error close to %s, cause: %s", getLevel(), e.getCause()); } dctx = null; }
@Override public void doClose() throws PerfCakeException { try { ctx.close(); } catch (final NamingException e) { throw new PerfCakeException("Failed to close LDAP context.", e.getCause()); } }
@Override public boolean startConnection() { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://" + getHostName() + ":" + port); if(binddn != null && password != null) { env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, binddn); env.put(Context.SECURITY_CREDENTIALS, password); } env.put("com.sun.jndi.ldap.connect.timeout", "" + getTimeout() * 1000); try { dctx = new InitialDirContext(env); } catch (NamingException e) { log(Level.ERROR, e, "Cannot connect to %s, cause: ", getLevel(), e.getCause()); return false; } log(Level.DEBUG, "Binding to: %s with dn: %s", env.get(Context.PROVIDER_URL), binddn); return dctx != null; }
} catch (NamingException e) { System.out.println("No Results for: " + targetDomain + "\nProblem: " + e.getLocalizedMessage() + " " + e.getCause());
dirContext.bind(dest, object); } catch (NamingException e) { if (e.getCause() instanceof FileNotFoundException) {
dirContext.bind(dest, object); } catch (NamingException e) { if (e.getCause() instanceof FileNotFoundException) {
LOGGER.error(msg, userName, url); String m = NestedExceptionUtils.buildMessage(e.getMessage(), e .getCause()); LOGGER.error(m, e); if (e instanceof AuthenticationException
dirContext.bind(dest, object); } catch (NamingException e) { if (e.getCause() instanceof FileNotFoundException) {
dirContext.bind(dest, object); } catch (NamingException e) { if (e.getCause() instanceof FileNotFoundException) {
dirContext.bind(dest, object); } catch (NamingException e) { if (e.getCause() instanceof FileNotFoundException) {
Throwable cause = nx.getCause(); while (cause != null)
resources.bind(dest, object); } catch (NamingException e) { if (e.getCause() instanceof FileNotFoundException) {
Throwable cause = nx.getCause(); while (cause != null)
resources.bind(dest, object); } catch (NamingException e) { if (e.getCause() instanceof FileNotFoundException) {
} catch (NamingException ex) { if (ex instanceof NameNotFoundException || ex.getCause() instanceof NameNotFoundException) { if (TraceEjb.isDebugIc()) { TraceEjb.interp.log(BasicLevel.DEBUG, "Cannot find destination JNDI name " + destJName, ex);