javax.naming.directory.DirContext#destroySubcontext ( )源码实例Demo

下面列出了javax.naming.directory.DirContext#destroySubcontext ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openbd-core   文件: ldapConnection.java
/**
 * deletes the entry with the set DN.
 */

public void delete() throws NamingException{
  //Get a reference to a directory context
  DirContext ctx = new InitialDirContext(env);
  ctx.destroySubcontext(dn);
  ctx.close();
}
 
源代码2 项目: scriptella-etl   文件: LdifScript.java
/**
 * Adds/modifies ctx using entry information.
 *
 * @param ctx directory context to use for change.
 * @param e   entry with change description.
 * @throws NamingException if operation with directory failed.
 */
static void modify(DirContext ctx, final Entry e) throws NamingException {
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Processing " + e);
    }
    Attributes atts = e.getAttributes();
    final String rootDn = ctx.getNameInNamespace();
    if (atts != null) { //If add entry
        ctx.createSubcontext(getRelativeDN(rootDn, e.getDn()), e.getAttributes());
    } else if (e.isChangeDelete()) {
        ctx.destroySubcontext(getRelativeDN(rootDn, e.getDn()));
    } else if (e.isChangeModDn() || e.isChangeModRdn()) {
        Name newRdn;
        if (e.getNewSuperior() != null) { //If new superior
            newRdn = getRelativeDN(rootDn, e.getNewSuperior());
        } else { //otherwise use DN as a base
            newRdn = getRelativeDN(rootDn, e.getDn());
            newRdn.remove(newRdn.size() - 1);
        }
        newRdn.add(e.getNewRdn());
        ctx.addToEnvironment("java.naming.ldap.deleteRDN", String.valueOf(e.isDeleteOldRdn()));
        ctx.rename(getRelativeDN(rootDn, e.getDn()), newRdn);
        ctx.removeFromEnvironment("java.naming.ldap.deleteRDN");//a better solution to use the previous value

    } else {
        List<ModificationItem> items = e.getModificationItems();
        ctx.modifyAttributes(getRelativeDN(rootDn, e.getDn()),
                items.toArray(new ModificationItem[items.size()]));
    }
}
 
源代码3 项目: jeecg   文件: LdapUtil.java
/**
 * 删除
 * 
 * @param dn
 */
public static void delete(String dn, DirContext dc) {
	try {
		dc.destroySubcontext(dn);
	} catch (Exception e) {
		LogUtil.error("Exception in delete():" + e);
	}
}