From 1ef68ca08978e6e9552e57c29f52dab33ab2b5c3 Mon Sep 17 00:00:00 2001 From: Mattias Hellborg Arthursson Date: Tue, 5 Nov 2013 08:56:09 +0100 Subject: [PATCH] LDAP-277: Now using index (if specified) when populating DnAttribute values. --- .../ldap/odm/core/impl/DefaultObjectDirectoryMapper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java b/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java index b0f0d24b..5f8a85d1 100644 --- a/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java +++ b/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java @@ -299,7 +299,14 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper { DnAttribute dnAttribute = attributeInfo.getDnAttribute(); if(dnAttribute != null) { - String dnValue = LdapUtils.getStringValue(dn, dnAttribute.value()); + String dnValue; + int index = dnAttribute.index(); + + if(index != -1) { + dnValue = LdapUtils.getStringValue(dn, index); + } else { + dnValue = LdapUtils.getStringValue(dn, dnAttribute.value()); + } field.set(result, dnValue); } }