Skip to content

Commit becfdc9

Browse files
orlandossojzheaux
authored andcommitted
Update ReturnAttributes Override
Issue gh-465
1 parent 264da5a commit becfdc9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/src/main/java/org/springframework/ldap/core/LdapTemplate.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -1830,8 +1830,10 @@ public <T> List<T> find(Name base, Filter filter, SearchControls searchControls,
18301830
}
18311831

18321832
// extend search controls with the attributes to return
1833-
String[] attributes = odm.manageClass(clazz);
1834-
searchControls.setReturningAttributes(attributes);
1833+
if (isNotCustomReturningAttributes(searchControls)) {
1834+
String[] attributes = this.odm.manageClass(clazz);
1835+
searchControls.setReturningAttributes(attributes);
1836+
}
18351837

18361838
if (LOG.isDebugEnabled()) {
18371839
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) {
18771879

18781880
return result.get(0);
18791881
}
1882+
1883+
private boolean isNotCustomReturningAttributes(SearchControls searchControls) {
1884+
return searchControls.getReturningAttributes() == null || searchControls.getReturningAttributes().length == 0;
1885+
}
18801886

18811887
/**
18821888
* The status of an authentication attempt.

0 commit comments

Comments
 (0)