public Map<String, String> getAttributes(String username) {
        Map<String, String> userAttributes = new HashMap<>();
        // Un-escape username.
        username = JID.unescapeNode(username);
        DirContext ctx = null;
        try {
            Rdn[] userRDN = manager.findUserRDN(username);
            // Build list of attributes to load from LDAP
            Map<String, PropertyMapping> ldapMappings = getLdapAttributes();
            Set<String> fields = new HashSet<>();
            for (PropertyMapping mapping : ldapMappings.values()) {
                fields.addAll(mapping.getFields());
            }
            fields.add(manager.getUsernameField());
            // Load records
            ctx = manager.getContext(manager.getUsersBaseDN(username));
            Attributes attrs = ctx.getAttributes(LdapManager.escapeForJNDI(userRDN), fields.toArray(new String[]{}));
            // Build answer
            for (Map.Entry<String, PropertyMapping> entry : ldapMappings.entrySet()) {
                String attribute = entry.getKey();
                String value = getPropertyValue(entry.getValue(), attrs);
                userAttributes.put(attribute, value);
            }
        }
        catch (Exception e) {
            Log.error("An error occurred while trying to get attributes for user: {}", username, e);
            // TODO something else?
        }
        finally {
            try {
                if (ctx != null) {
                    ctx.close();
                }
            }
            catch (Exception ex) {
                Log.debug("An exception occurred while trying to close a LDAP context after trying to get attributes for user {}.", username, ex);
            }
        }
        return userAttributes;
    }
Returns a list of attributes and their LDAP values found in LDAP for the specified username.

@param username the username of the user to get his attributes from LDAP.
@return a list of attributes and their LDAP values found in LDAP for the specified username.
xmppserver/src/main/java/org/jivesoftware/admin/LdapUserTester.java