On LDAP import, a custom attribute with multiple values only sets one value

Description

Setting ldap.user.custom.mappings in portal-ext.properties allows additional LDAP attributes to be copied into Custom Attributes of the User (thanks, this is wonderful). However, if one of the attributes has multiple values, only one of the values will be copied. It would be better if all the values were copied over as a comma delimited list.

In LDAPUtil,java line 64:

Object obj = attribute.get();

From the Javadoc for Attribute.java:

  • Retrieves one of this attribute's values.

  • If the attribute has more than one value and is unordered, any one of

  • the values is returned.

  • If the attribute has more than one value and is ordered, the

  • first value is returned.

Rather, LDAPUtil could check the size() and if it is over 1, return all the values as a comma delimited list.

Attachments

1
  • 01 Jun 2011, 02:22 PM

Activity

Show:

Matthew Lee August 20, 2012 at 5:51 PM

Committed on:
Portal 6.1.x CE GIT ID: ae054c25efe0c6a2c8e770c3e088503079acc678.
Portal 6.2.x GIT ID: e7447dbb56b17d57b56e9611f41cf9b48ece0da5.

Juan Fernández May 16, 2011 at 1:50 AM

Hi Matthew:
I moved this ticket to "community backlog", meaning that his feature is interesting and can be implemented by the community or Liferay as an improvement for a future version.
We will appreciate if you or any community member contribute this functionality
Thanks for your feedback!

Matthew Smith May 13, 2011 at 12:42 PM

Something along the lines of

Attribute attribute = attributes.get(id);
int size = attribute.size();
String value;
if(size > 1) {
StringBuilder sb = new StringBuilder(attribute.get(0).toString());
for (int i = 1; i < size; i++) {
sb.append(",").append(attribute.get:info.toString());
}
value = sb.toString();
}

Completed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Labels

Branch Version/s

6.1.x

Backported to Branch

Committed

Liferay Contributor's Agreement

Accept

Affects versions

Priority

Zendesk Support

Created May 13, 2011 at 12:32 PM
Updated June 26, 2023 at 5:53 AM
Resolved August 21, 2012 at 10:16 AM