Example usage for javax.naming.directory DirContext rebind

List of usage examples for javax.naming.directory DirContext rebind

Introduction

In this page you can find the example usage for javax.naming.directory DirContext rebind.

Prototype

public void rebind(String name, Object obj, Attributes attrs) throws NamingException;

Source Link

Document

Binds a name to an object, along with associated attributes, overwriting any existing binding.

Usage

From source file:org.springframework.ldap.core.LdapTemplate.java

public void rebind(final Name dn, final Object obj, final Attributes attributes) {

    executeReadWrite(new ContextExecutor() {
        public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
            ctx.rebind(dn, obj, attributes);
            return null;
        }//from   w w  w.  j a v a 2  s  . c o  m
    });
}

From source file:org.springframework.ldap.core.LdapTemplate.java

public void rebind(final String dn, final Object obj, final Attributes attributes) {

    executeReadWrite(new ContextExecutor() {
        public Object executeWithContext(DirContext ctx) throws javax.naming.NamingException {
            ctx.rebind(dn, obj, attributes);
            return null;
        }/*from ww w .  j a  va  2s.  c  o  m*/
    });
}

From source file:org.springframework.ldap.demo.dao.PersonDaoImpl.java

public void update(Person person) {
    DirContext ctx = createAuthenticatedContext();
    String dn = buildDn(person);/*from  w  w  w . j  a  va2  s  . co  m*/
    try {
        ctx.rebind(dn, null, getAttributesToBind(person));
    } catch (NamingException e) {

        throw new RuntimeException(e);
    } finally {
        if (ctx != null) {
            try {
                ctx.close();
            } catch (Exception e) {
                // Never mind this.
            }
        }
    }
}