public void close() throws KettleException { if ( ctx != null ) { try { ctx.close(); if ( log.isBasic() ) { log.logBasic( BaseMessages.getString( PKG, "LDAPInput.log.Disconnection.Done" ) ); } } catch ( Exception e ) { log.logError( BaseMessages.getString( PKG, "LDAPInput.Exception.ErrorDisconecting", e.toString() ) ); log.logError( Const.getStackTracker( e ) ); } finally { ctx = null; } } } }
protected void safeClose(InitialLdapContext ic) { if(ic != null) { try { ic.close(); } catch (NamingException e) { } } } }
@Override public void close() { try { super.close(); } catch (NamingException e) { LOGGER.error("Failed to close LDAP context: {}", e.getMessage()); } } }
/** * {@inheritDoc} */ public void disconnect() { if ( jobThread != null ) { Thread t = jobThread; jobThread = null; t.interrupt(); } if ( context != null ) { try { context.close(); } catch ( NamingException e ) { // ignore } context = null; } isConnected = false; }
@Override public void close() throws NamingException { if (tls != null) { try { tls.close(); } catch (Exception err) { LOGGER.error("Could not close TLS", err); } } super.close(); } }
public void cancelRequested( StudioProgressMonitor.CancelEvent event ) { if ( monitor.isCanceled() ) { if ( jobThread != null && jobThread.isAlive() ) { jobThread.interrupt(); } if ( context != null ) { try { context.close(); } catch ( NamingException ne ) { } isConnected = false; context = null; } isConnected = false; } } };
if (ctx != null) { try { ctx.close(); } catch (NamingException e) { e.printStackTrace();
if (ctx != null) { try { ctx.close(); } catch (NamingException e) { e.printStackTrace();
if (ctx != null) { try { ctx.close(); } catch (NamingException e) { e.printStackTrace();
/** * Find account by account name. * * @param accountName the account name * @return the search result * @throws NamingException the naming exception */ protected SearchResult findAccountByAccountName(String accountName) throws NamingException { String searchFilter = String.format(searchFilterPattern, accountName); SearchControls searchControls = new SearchControls(); searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); InitialLdapContext ctx = new InitialLdapContext(env, null); try { NamingEnumeration<SearchResult> results = ctx.search(searchBase, searchFilter, searchControls); if (!results.hasMoreElements()) { throw new UserConfigLoaderException("LDAP Search returned no accounts"); } SearchResult searchResult = results.nextElement(); if (results.hasMoreElements()) { throw new UserConfigLoaderException("More than one account found in ldap search"); } return searchResult; } finally { ctx.close(); } }
/** * Closes LDAP context, effectively closing the connection to LDAP. * (non-Javadoc) */ @Override public void close() { if(initCtx != null) { try { initCtx.close(); } catch(NamingException e) { LogManager.logDetail(LogConstants.CTX_CONNECTOR, LDAPPlugin.Util.getString("LDAPConnection.contextCloseError",e.getExplanation())); //$NON-NLS-1$ } } LogManager.logDetail(LogConstants.CTX_CONNECTOR,"LDAP context has been closed."); //$NON-NLS-1$ }
/** * Closes LDAP context, effectively closing the connection to LDAP. * (non-Javadoc) */ @Override public void close() { if(initCtx != null) { try { initCtx.close(); } catch(NamingException e) { LogManager.logDetail(LogConstants.CTX_CONNECTOR, LDAPPlugin.Util.getString("LDAPConnection.contextCloseError",e.getExplanation())); //$NON-NLS-1$ } } LogManager.logDetail(LogConstants.CTX_CONNECTOR,"LDAP context has been closed."); //$NON-NLS-1$ }
public boolean deleteUser(String name) { InitialLdapContext ctx = null; try { ctx = initialiseContext(); String userDN = getUserDN(name); ctx.destroySubcontext(userDN); return true; } catch (NamingException ex) { throw new IdentityManagementException("Failed to delete user", ex); } finally { if (ctx != null) { try { ctx.close(); } catch (NamingException ex) {} } } }
/** * Bind to the LDAP server for authentication */ private boolean createLdapInitContext(String username, Object credential) throws Exception { // Get the admin context for searching InitialLdapContext ctx = null; ClassLoader currentTCCL = SecurityActions.getContextClassLoader(); try { if (currentTCCL != null) SecurityActions.setContextClassLoader(null); ctx = constructInitialLdapContext(bindDN, bindCredential); // Validate the user by binding against the userDN bindDNAuthentication(ctx, username, credential, baseDN, baseFilter); } catch(Exception e) { throw e; } finally { if (ctx != null) ctx.close(); if (currentTCCL != null) SecurityActions.setContextClassLoader(currentTCCL); } return true; }
public boolean changePassword(String name, String password) { InitialLdapContext ctx = null; try { ctx = initialiseContext(); BasicAttribute passwordAttrib = new BasicAttribute(getUserPasswordAttribute(), password); ModificationItem mod = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, passwordAttrib); ctx.modifyAttributes(getUserDN(name), new ModificationItem[] { mod }); return true; } catch (NamingException ex) { throw new IdentityManagementException("Failed to change password", ex); } finally { if (ctx != null) { try { ctx.close(); } catch (NamingException ex) {} } } }