protected Attributes getLDAPAttributes()

in ldap/src/java/org/apache/fulcrum/security/ldap/LDAPUserManagerImpl.java [689:760]


    protected Attributes getLDAPAttributes(User user)
            throws NamingException
    {
        Attributes attribs = new BasicAttributes();

        // Set the objectClass
        {
            Attribute attr = new BasicAttribute("objectClass", this.ldapObjectClass);
            attribs.put(attr);
        }

        // Set the User id. This should be numeric and must not be null
        Object value = user.getId();

        if (value != null)
        {
            Attribute attr = new BasicAttribute(this.ldapUserid, value);
            attribs.put(attr);
        }

        // Set the Username.
        value = user.getName();

        if (value != null)
        {
            Attribute attr = new BasicAttribute(this.ldapUsername, value);
            attribs.put(attr);
        }

        // Set the Password
        value = user.getPassword();

        if (value != null)
        {
            Attribute attr = new BasicAttribute(this.ldapPassword, value);
            attribs.put(attr);
        }

        if (user instanceof LDAPUser)
        {
            LDAPUser u = (LDAPUser)user;

            // Set the Firstname.
            value = u.getFirstName();

            if (value != null)
            {
                Attribute attr = new BasicAttribute(this.ldapFirstname, value);
                attribs.put(attr);
            }

            // Set the Lastname.
            value = u.getLastName();

            if (value != null)
            {
                Attribute attr = new BasicAttribute(this.ldapLastname, value);
                attribs.put(attr);
            }

            // Set the E-Mail.
            value = u.getEmail();

            if (value != null)
            {
                Attribute attr = new BasicAttribute(this.ldapEmail, value);
                attribs.put(attr);
            }
        }

        return attribs;
    }