-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make Get(Raw)AttributeValues compare case insensitive #111
Conversation
would love to have this! |
func TestGetAttributeValue(t *testing.T) { | ||
dn := "testDN" | ||
attributes := map[string][]string{ | ||
"Alpha": {"value"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what should happen if you have {"alpha":{"a","b"}, "ALPHA": {"c", "d"}}
and you search for "Alpha"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that possible? isn't the attribute name case insensitive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we at least add a test case with attribute names differing only in case and document via the tests how we'd handle it? That way at least it's more obvious.
I'd like to see the case sensitivity to be toggled by a package variable ( |
I still think it's a mistake to compress the value space by default. Explicitly case-insensitive lookup functions seem clearer to me. Would also need to define the behavior for that (does it prefer an exact matching name over a case insensitive name match that comes first in order? Does it aggregate values specified for names that differ only by case?) |
fe017e8
to
757d81e
Compare
these are the case insensitive counter parts, e.g. GetAttributeValue <=> GetEqualFoldAttributeValue using strings.EqualFold to compare the attrribute names fixes go-ldap#109 go-ldap#129
2481b09
to
9c998c4
Compare
rebased against 99171d7 and squashed |
@johnweldon @liggitt can we merge this? |
LDAP itself doesn't match attributes case-sensitively, so a query for (fOO=bar) will return all the entries having `foo: bar`, regardless of how the attribute name is defined in the schema. However, the result entries we get will have the case according to what the server returned. So, assuming the schema calls it `foo`, this is what we're given. Now, for certain attributes that are user-configurable -- NameAttr for example -- this can cause trouble: the query returns the right results, but the LDAP connector can't make sense of it as it's looking for an attribute called `fOO`. The real life case underlying this conundrum is Active Directory's sAMAccountName. Note that this is a bit of a workaround. Ideally, we'd use `(*ldap.Entry).GetAttributes(string) []string` to access the attributes; but until the case sensitivity issue is fixed there[1], changing the way we read the results doesn't help us. [1]: go-ldap/ldap#111 Signed-off-by: Stephan Renatus <[email protected]>
I'd like to have this fix as well. Any ETA for merging it? |
@liggitt 🏓 Any news regarding this? 😃 |
func TestGetAttributeValue(t *testing.T) { | ||
dn := "testDN" | ||
attributes := map[string][]string{ | ||
"Alpha": {"value"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we at least add a test case with attribute names differing only in case and document via the tests how we'd handle it? That way at least it's more obvious.
This is the same way an LDAP server compares during a search request.
Fixes #109