Skip to content

Loading…

Incorrect response with return_result=false in Net::LDAP.search #3

Merged
merged 1 commit into from

4 participants

@dulanov

If we received some entries the nil must be returned instead of true.

@RoryO

Thanks for this!

@RoryO RoryO merged commit 7dd6c3a into ruby-ldap:master
@just-broken

This commit appears wrong. The method will always return a non-nil (but possibly empty) result set if :return_result argument is true, even if the .search call fails with an error. Yet the documentation states, “If you request a result set and #search fails with an # error, it will return nil.” The previous behavior was also incorrect for the same reason. Is the code wrong or is the documentation wrong? Or have I missed something?

I think you are right. With this approach, we do not know if our search did not give any results, or if there was an error, without calling get_operation_result. The method does not behave as documented (neither in this version, nor in the previous one). I'll open a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 27, 2011
  1. @dulanov
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/net/ldap.rb
View
2 lib/net/ldap.rb
@@ -642,7 +642,7 @@ def search(args = {})
end
end
- @result == 0 and result_set
+ result_set || @result == 0
end
# #bind connects to an LDAP server and requests authentication based on
Something went wrong with that request. Please try again.