Ensure LDAP filters are always parentheses-wrapped and run with &
#11303
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've gotten a few weird problems with LDAP filters under v6, and it mostly looks due to configuration quirks in how v5 handled filters versus how we do it in v6.
The way we used to assemble the filters before was:
(
&
(
)
)
But under v5, we started to allow Filters that were wrapped with parentheses.
So we need to support filters that look like:
&(cn=*)
(cn=*)
So what this does is assemble the query like this:
(&
, then the ensure-parentheses-wrapped-version of the filter, then the parentheses-wrapped auth querySo for the first example, a sample LDAP auth query might look like:
I've tested that, and that is a valid lookup, and gets you the results you'd expect.
For the second example, what you'd end up with is:
Caveats
uid=samaccountname
auth query, at all. I can't figure out where this got introduced, and I can't figure out how it ever worked, and I can't replicate anything with it at all. It seems to be a filter that will always return zero results, at least, on AD. Very weird.