Example usage for javax.naming.ldap LdapContext bind

List of usage examples for javax.naming.ldap LdapContext bind

Introduction

In this page you can find the example usage for javax.naming.ldap LdapContext bind.

Prototype

public void bind(Name name, Object obj) throws NamingException;

Source Link

Document

Binds a name to an object.

Usage

From source file:com.liferay.portal.security.ldap.internal.exportimport.LDAPUserExporterImpl.java

protected Binding addUser(long ldapServerId, LdapContext ldapContext, User user, Properties userMappings)
        throws Exception {

    Name name = new CompositeName();

    name.add(_portalToLDAPConverter.getUserDNName(ldapServerId, user, userMappings));

    Attributes attributes = _portalToLDAPConverter.getLDAPUserAttributes(ldapServerId, user, userMappings);

    ldapContext.bind(name, new PortalLDAPContext(attributes));

    Binding binding = _portalLDAP.getUser(ldapServerId, user.getCompanyId(), user.getScreenName(),
            user.getEmailAddress());//from  w  ww . j  ava  2s  . c  o m

    return binding;
}

From source file:com.liferay.portal.security.ldap.internal.exportimport.LDAPUserExporterImpl.java

protected Binding addGroup(long ldapServerId, LdapContext ldapContext, UserGroup userGroup, User user,
        Properties groupMappings, Properties userMappings) throws Exception {

    Name name = new CompositeName();

    name.add(_portalToLDAPConverter.getGroupDNName(ldapServerId, userGroup, groupMappings));

    Attributes attributes = _portalToLDAPConverter.getLDAPGroupAttributes(ldapServerId, userGroup, user,
            groupMappings, userMappings);

    ldapContext.bind(name, new PortalLDAPContext(attributes));

    Binding binding = _portalLDAP.getGroup(ldapServerId, userGroup.getCompanyId(), userGroup.getName());

    return binding;
}

From source file:org.apache.directory.server.core.jndi.ObjStateFactoryIT.java

@Test
public void testStateFactory() throws Exception {
    LdapContext sysRoot = getSystemContext(getService());

    sysRoot.addToEnvironment(Context.STATE_FACTORIES, PersonStateFactory.class.getName());
    Person p = new Person("Rodriguez", "Mr. Kerberos", "noices", "555-1212", "sn=erodriguez", "committer");
    sysRoot.bind("sn=Rodriguez, ou=users", p);
    Attributes attrs = sysRoot.getAttributes("sn=Rodriguez, ou=users");
    assertEquals("Rodriguez", attrs.get("sn").get());
    assertEquals("Mr. Kerberos", attrs.get("cn").get());
    assertTrue(ArrayUtils.isEquals(attrs.get("userPassword").get(), Strings.getBytesUtf8("noices")));
    assertEquals("555-1212", attrs.get("telephonenumber").get());
    assertEquals("sn=erodriguez", attrs.get("seealso").get());
    assertEquals("committer", attrs.get("description").get());
}