Skip to content

Commit a4819e5

Browse files
committed
Fix incorrect return value from search when :return_result => true and and search fails
1 parent 42bdeb9 commit a4819e5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/net/ldap.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ def search(args = {})
619619
end
620620

621621
args[:base] ||= @base
622-
result_set = (args and args[:return_result] == false) ? nil : []
622+
result_set = args[:return_result] == false ? nil : []
623623

624624
if @open_connection
625625
@result = @open_connection.search(args) { |entry|
@@ -642,7 +642,11 @@ def search(args = {})
642642
end
643643
end
644644

645-
result_set || @result == 0
645+
if args[:return_result]
646+
@result == 0 ? result_set : nil
647+
else
648+
@result == 0
649+
end
646650
end
647651

648652
# #bind connects to an LDAP server and requests authentication based on

0 commit comments

Comments
 (0)