public static String getPropertyValue( final PropertyMapping mapping, final Attributes attributes ) throws NamingException
    {
        String value = mapping.getDisplayFormat();
        for (String field : mapping.getFields()) {
            Attribute ldapField = attributes.get(field);
            if (ldapField != null) {
                String answer;
                Object ob = ldapField.get();
                if (ob instanceof String) {
                    answer = (String) ob;
                } else {
                    answer = Base64.getEncoder().encodeToString((byte[]) ob);
                }
                if ( mapping.isFirstMatchOnly()) {
                    // find and use the first non-null value.
                    if ( answer == null || answer.isEmpty() ) {
                        continue;
                    }
                    value = value.replace("{VALUE}", answer);
                    break;
                } else {
                    // replace all fields with values.
                    value = value.replace("{" + field + "}", answer);
                }
            }
        }

        return value;
    }
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