Skip to content

Conversation

@jzinn
Copy link

@jzinn jzinn commented Jan 27, 2013

When searching for attribute values that contain asterisks or backslashes, the search results are empty when they should not be.

For example I have an Active Directory group with cn value of special*group. A search with filter Net::LDAP::Filter.begins(:cn, "special*g") should find this group, but doesn't.

I compared Wireshark captures of this query with one using the ldapsearch command line tool. The bytes sent on the wire by ldapsearch ... '(cn=special\2Ag*)', have a single 0x2a byte (the hex value of the asterisk character) between special and g, whereas the net-ldap gem sends three bytes, one for \, one for 2, and one for A.

This pull request uses the unescape method to make the net-ldap gem behave like ldapsearch, and causes my search to return the expected results. However, I wonder if the net-ldap gem doesn't already work this way to prevent existing client code from breaking due to unexpected unescaping. If so, what workaround would solve my problem?

When the unescape method was introduced, the #to_ber method was updated to use unescape in some places. This pull request updates #to_ber to use unescape a few more times. I'm curious if there is a reason the previous commit decided not to use unescape where this pull request adds it.

RoryO pushed a commit that referenced this pull request Jul 22, 2013
Unescape escaped filter characters in #to_ber
@RoryO RoryO merged commit 9ade653 into ruby-ldap:master Jul 22, 2013
astratto pushed a commit to astratto/ruby-net-ldap that referenced this pull request Dec 18, 2015
Unescape escaped filter characters in #to_ber
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