Skip to content

Commit

Permalink
GUACAMOLE-893: Fix issue where just checking for attribute presence.
Browse files Browse the repository at this point in the history
  • Loading branch information
necouchman committed Oct 11, 2019
1 parent 10b3adc commit a037146
Showing 1 changed file with 17 additions and 5 deletions.
Expand Up @@ -37,6 +37,7 @@
import org.apache.directory.api.ldap.model.filter.EqualityNode;
import org.apache.directory.api.ldap.model.filter.ExprNode;
import org.apache.directory.api.ldap.model.filter.OrNode;
import org.apache.directory.api.ldap.model.filter.PresenceNode;
import org.apache.directory.api.ldap.model.message.Referral;
import org.apache.directory.api.ldap.model.message.SearchRequest;
import org.apache.directory.api.ldap.model.name.Dn;
Expand Down Expand Up @@ -149,14 +150,25 @@ public ExprNode generateQuery(ExprNode filter,
// Include all attributes within OR clause
OrNode attributeFilter = new OrNode();

// Add equality comparison for each possible attribute
attributes.forEach(attribute ->
attributeFilter.addNode(new EqualityNode(attribute,
(attributeValue != null ? attributeValue : "*")))
);
// If value is defined, check each attribute for that value.
if (attributeValue != null) {
attributes.forEach(attribute ->
attributeFilter.addNode(new EqualityNode(attribute,
attributeValue))
);
}

// If no value is defined, just check for presence of attribute.
else {
attributes.forEach(attribute ->
attributeFilter.addNode(new PresenceNode(attribute))
);
}

searchFilter.addNode(attributeFilter);

logger.trace("Sending LDAP filter: \"{}\"", searchFilter.toString());

return searchFilter;

}
Expand Down

0 comments on commit a037146

Please sign in to comment.