Skip to content
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

Ignore extra spaces in baseDN and attributes when creating LDAP search request #12086

Closed
wants to merge 1 commit into from

Conversation

mfojtik
Copy link
Contributor

@mfojtik mfojtik commented Dec 1, 2016

No description provided.

@mfojtik
Copy link
Contributor Author

mfojtik commented Dec 1, 2016

@soltysh
Copy link
Contributor

soltysh commented Dec 1, 2016

I don't know that much about LDAP, but seeing this:

uniqueMember: uid=user01, ou=users, dc=example, dc=com
uniqueMember: uid=user02,ou=users,dc=example, dc=com
uniqueMember: uid=user03, ou=users, dc=example, dc=com

seems not accurate. It's as if the server is having a bad day and putting spaces randomly in some entries and others not. I'm guessing it might be misconfiguration somewhere, but not 100% sure.

return -1
}
return r
}
if strings.EqualFold(o.QueryAttribute, "dn") {
if _, err := ldap.ParseDN(attributeValue); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use result of this function instead of manually parsing and checking validity?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, we should be comparing the structured forms

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -104,11 +105,17 @@ type LDAPQueryOnAttribute struct {
// NewSearchRequest creates a new search request from the identifying query by internalizing the value of
// the attribute to be filtered as well as any attributes that need to be recovered
func (o *LDAPQueryOnAttribute) NewSearchRequest(attributeValue string, attributes []string) (*ldap.SearchRequest, error) {
removeSpaces := func(r rune) rune {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't blindly remove spaces, they are significant in values, but not between values

return -1
}
return r
}
if strings.EqualFold(o.QueryAttribute, "dn") {
if _, err := ldap.ParseDN(attributeValue); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, we should be comparing the structured forms

},
expectedError: false,
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a test that ensures we still correctly identify mismatched white space inside the values as being out of scope

@mfojtik
Copy link
Contributor Author

mfojtik commented Dec 1, 2016

@enj fyi

@liggitt
Copy link
Contributor

liggitt commented Dec 1, 2016

requires go-ldap/ldap#98

@liggitt
Copy link
Contributor

liggitt commented Dec 1, 2016

closing in favor of #12105

@liggitt liggitt closed this Dec 1, 2016
@mfojtik mfojtik deleted the fix-spaces-ldap branch September 5, 2018 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants