-
Notifications
You must be signed in to change notification settings - Fork 252
Fix size option for ldap.search method #140
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
Conversation
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
@jch I will do :) |
👍 for a more readable constant. It's already defined higher in this file at https://github.com/ruby-ldap/ruby-net-ldap/blob/master/lib/net/ldap.rb#L329. You can do: ResultStrings.value("Size Limit Exceeded") I agree with you that I'd prefer the constant, but in the interest of keeping this PR focused, I think reusing the existing lookup is fine. |
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
@jch I removed magic number and unnecessary |
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This disables a failing test that won't pass without changing the behavior of Net::LDAP#search (and Net::LDAP::Connection#search). This is due to sizeLimitExceeded being treated as a failure instead of a deliberate termination of search results. Instead of returning the partial results, we currently return none. cc @jch @schaary
when ResultStrings.key("Success") | ||
# everything good | ||
result_set | ||
when ResultStrings.key("Size Limit Exceeded") |
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.
I'd like to use a constant in this case. I didn't see one already defined, though, but I'd be in favor of one (or a few) for this.
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.
👍 We can define the constants, and then define ResultStrings
values in terms of those constants.
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.
Heh, not to contradict @jch, we can worry about this in a followup PR.
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.
👍
Thanks for doing this! It was also on my shortlist :) One final thing: would like to see an assertion for the returned results matching the results yielded! A new test in https://github.com/randx/ruby-net-ldap/blob/fix-size-option-in-search/test/integration/test_search.rb would be perfect. |
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tests added. Build is green 😄. Anything else? |
Also thank you for fast review! |
👍 diff looks good to me. @jch? |
Fix size option for ldap.search method
assert_equal [entry], result | ||
assert_equal [entry], payload[:result] | ||
assert_equal "(uid=user1)", payload[:filter] | ||
assert_equal result.size, payload[:size] |
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.
👌 perfect!
Is it planned any gem release soon? |
Fix size option for ldap.search method
This PR fixes issue #75.
Problem
When I search for ldap users and use
size
option I gotnil
result if amount of users in LDAP more than number provided insize
options. So if you want to get first 50 LDAP users you get nil because its more than 50 users :)Describing problem in more simple way it looks like this for me:
Solution
Just check for
4
result_code from LDAP and return result in this case too.Possible improvemens
I dont like this
0
and4
magic numbers but I afraid to touch code unrelated to my fix. If you ask I can add4
as constant likeLDAP_SIZE_LIMIT_EXCEEDED
Thank you!!!