From df40b394653e84de4fb846634bf0040799397e79 Mon Sep 17 00:00:00 2001 From: Orlando Souto Date: Wed, 3 Feb 2021 19:19:02 -0300 Subject: [PATCH] Update ReturnAttributes Override Issue gh-465 --- .../org/springframework/ldap/core/LdapTemplate.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java index c40280667c..9098c02983 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java @@ -1830,8 +1830,10 @@ public List find(Name base, Filter filter, SearchControls searchControls, } // extend search controls with the attributes to return - String[] attributes = odm.manageClass(clazz); - searchControls.setReturningAttributes(attributes); + if (isNotCustomReturningAttributes(searchControls)) { + String[] attributes = this.odm.manageClass(clazz); + searchControls.setReturningAttributes(attributes); + } if (LOG.isDebugEnabled()) { LOG.debug(String.format("Searching - base=%1$s, finalFilter=%2$s, scope=%3$s", base, finalFilter, searchControls)); @@ -1877,6 +1879,10 @@ else if (result.size() != 1) { return result.get(0); } + + private boolean isNotCustomReturningAttributes(SearchControls searchControls) { + return searchControls.getReturningAttributes() == null || searchControls.getReturningAttributes().length == 0; + } /** * The status of an authentication attempt.