protected void removeNodeSpi() throws BackingStoreException { try { ctx.destroySubcontext( "" ); } catch ( NamingException e ) { throw new BackingStoreException( e ); } ctx = null; changes.clear(); keyToChange.clear(); }
private void doDeleteChildrenRecursively(String distinguishName) throws NamingException { SearchControls sc = new SearchControls(); sc.setSearchScope(SearchControls.ONELEVEL_SCOPE); NamingEnumeration<SearchResult> ne = ctx.search(distinguishName, DEFAULT_FILTER, sc); while (ne.hasMore()) { SearchResult sr = (SearchResult) ne.next(); String childrenDn = rewriteBase(sr.getName() + "," + distinguishName); deleteChildrenRecursively(childrenDn); } ctx.destroySubcontext(new LdapName(distinguishName)); }
private void removeMembership(LdapContext ctx, String name) throws NamingException { NamingEnumeration<SearchResult> results = null; // need to escape '*' symbol since it is a special symbol for organization service // and LDAP protocol, but has different meanings if ("*".equals(name)) { name = "\\2a"; } try { SearchControls constraints = new SearchControls(); constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); String filter = ldapAttrMapping.membershipTypeNameAttr + "=" + name; results = ctx.search(ldapAttrMapping.groupsURL, filter, constraints); while (results.hasMore()) { SearchResult sr = results.next(); ctx.destroySubcontext(sr.getNameInNamespace()); cacheHandler.remove(CacheHandler.MEMBERSHIPTYPE_PREFIX + name, CacheType.MEMBERSHIP); } } finally { if (results != null) results.close(); } }
/** * LDAP delete operation. Deletes an entry from the directory. * * @param dn DN of the entry * @throws NamingException if DN can not be resolved */ public void delete(final String dn) throws NamingException { if (!exists(dn)) { throw new NameNotFoundException("Entry " + dn + " does not exist!"); } WithContext<Object> action = ctx -> { ctx.destroySubcontext(dn); return null; }; performWithContext(action); }
@Override public void removeUser(String username, LdapContext context, LdapAuthConfiguration configuration) throws NoSuchLdapUserException, LdapDAOException { log.info("Remove user: " + username); try { context = (LdapContext) context.lookup(StringUtils.defaultString(configuration.getUserBaseDn(), "")); context.destroySubcontext(configuration.getUserIdAttribute() + "=" + username); } catch (NamingException e) { String message = "Failed to remove user: " + username; throw new LdapDAOException(message, e); } }
public void deleteEntityByDn(String dn) { try { LdapContext context = connectionService.getContext(); SearchControls searchControls = new SearchControls(); searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); NamingEnumeration<SearchResult> children = context.search(dn, "(objectclass=*)", searchControls); TreeSet<String> dnsToDelete = new TreeSet<>(new DnComparator(true)); while (children.hasMoreElements()) { SearchResult childResult = children.nextElement(); String childDn = childResult.getNameInNamespace(); dnsToDelete.add(childDn); } for (String s : dnsToDelete) { context.destroySubcontext(s); } } catch (NamingException e) { throw new CukesRuntimeException("Cannot delete entity by dn " + dn, e); } finally { connectionService.close(); } }
public void deleteEntityByDn(String dn) { try { LdapContext context = connectionService.getContext(); SearchControls searchControls = new SearchControls(); searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); NamingEnumeration<SearchResult> children = context.search(dn, "(objectclass=*)", searchControls); TreeSet<String> dnsToDelete = new TreeSet<>(new DnComparator(true)); while (children.hasMoreElements()) { SearchResult childResult = children.nextElement(); String childDn = childResult.getNameInNamespace(); dnsToDelete.add(childDn); } for (String s : dnsToDelete) { context.destroySubcontext(s); } } catch (NamingException e) { throw new CukesRuntimeException("Cannot delete entity by dn " + dn, e); } finally { connectionService.close(); } }
public void removeUser( String username, LdapContext context, LdapAuthConfiguration configuration ) throws NoSuchLdapUserException, LdapDAOException { getLogger().info( "Searching for user: " + username ); try { context = (LdapContext) context.lookup( StringUtils.defaultString( configuration.getUserBaseDn(), "" ) ); context.destroySubcontext( configuration.getUserIdAttribute() + "=" + username ); } catch ( NamingException e ) { String message = "Failed to remove user: " + username; throw new LdapDAOException( message, e ); } }
removeAllSubtree(ctx, sr.getNameInNamespace()); ctx.destroySubcontext(dn); String groupId = buildGroup(dn, null).getId(); cacheHandler.remove(groupId, CacheType.GROUP);
deleteChildrenRecursively(rewriteBase(jm.getDistinguishName())); } else { ctx.destroySubcontext(new LdapName(rewriteBase(jm.getDistinguishName())));
ctx.destroySubcontext(membershipDN); cacheHandler.remove(cacheHandler.getMembershipKey(membership), CacheType.MEMBERSHIP);
private void executeDelete() throws TranslatorException { Condition criteria = ((Delete)command).getWhere(); // since we have the exact same processing rules for criteria // for updates and deletes, we use a common private method to do this. // note that this private method will throw a ConnectorException // for illegal criteria, which we deliberately don't catch // so it gets passed on as is. String distinguishedName = getDNFromCriteria(criteria); // just try to delete an LDAP entry using the DN // specified in the DELETE operation. If it isn't // legal, we'll get a NamingException back, whose explanation // we'll return in a ConnectorException try { ldapCtx.destroySubcontext(distinguishedName); } catch (NamingException ne) { final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.deleteFailed",distinguishedName,ne.getExplanation()); //$NON-NLS-1$ throw new TranslatorException(msg); // don't remember why I added this generic catch of Exception, // but it does no harm... } catch (Exception e) { final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.deleteFailedUnexpected",distinguishedName); //$NON-NLS-1$ throw new TranslatorException(e, msg); } }
ldapCtx.destroySubcontext(theDN); this.updateCount = 1; } catch (NamingException ne) {
modCtx.destroySubcontext( getSaveJndiName( dn ) );
@Override public Response<Void> delete(final DeleteRequest request) throws LdapException { Response<Void> response = null; LdapContext ctx = null; try { try { ctx = initializeContext(request); ctx.destroySubcontext(new LdapName(request.getDn())); response = createResponse(request, null, ResultCode.SUCCESS, null, ctx); } finally { if (ctx != null) { ctx.close(); } } } catch (ReferralException e) { final String[] refUrls = e.getReferralInfo() != null ? new String[] {(String) e.getReferralInfo()} : null; response = createResponse(request, null, ResultCode.REFERRAL, refUrls, ctx); } catch (NamingException e) { processNamingException(request, e, null, ctx); } return response; }
@Override public Response<Void> delete(final DeleteRequest request) throws LdapException { Response<Void> response = null; LdapContext ctx = null; try { try { ctx = initializeContext(request); ctx.destroySubcontext(new LdapName(request.getDn())); response = createResponse(request, null, ResultCode.SUCCESS, null, ctx); } finally { if (ctx != null) { ctx.close(); } } } catch (ReferralException e) { final String[] refUrls = e.getReferralInfo() != null ? new String[] {(String) e.getReferralInfo()} : null; response = createResponse(request, null, ResultCode.REFERRAL, refUrls, ctx); } catch (NamingException e) { processNamingException(request, e, null, ctx); } return response; }
@Override public Response<Void> delete(final DeleteRequest request) throws LdapException { Response<Void> response = null; LdapContext ctx = null; try { try { ctx = initializeContext(request); ctx.destroySubcontext(new LdapName(request.getDn())); response = createResponse(request, null, ResultCode.SUCCESS, null, ctx); } finally { if (ctx != null) { ctx.close(); } } } catch (ReferralException e) { final String[] refUrls = e.getReferralInfo() != null ? new String[] {(String) e.getReferralInfo()} : null; response = createResponse(request, null, ResultCode.REFERRAL, refUrls, ctx); } catch (NamingException e) { processNamingException(request, e, null, ctx); } return response; }
ctx.destroySubcontext(profileDN); return profile;
ctx.destroySubcontext(membershipTypeDN); cacheHandler.remove(name, CacheType.MEMBERSHIPTYPE);
ctx.destroySubcontext(userDN); if (os != null)