Skip to content

Commit d6aa24e

Browse files
committed
Changed back return values in API methods to match what documentation says
1 parent 51597ea commit d6aa24e

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lib/net/ldap.rb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -519,15 +519,17 @@ def self.open(args)
519519
# response codes instead of a simple numeric code.
520520
#++
521521
def get_operation_result
522+
result = @result
523+
result = result.result if result.is_a?(Net::LDAP::PDU)
522524
os = OpenStruct.new
523-
if @result.is_a?(Hash)
525+
if result.is_a?(Hash)
524526
# We might get a hash of LDAP response codes instead of a simple
525527
# numeric code.
526-
os.code = (@result[:resultCode] || "").to_i
527-
os.error_message = @result[:errorMessage]
528-
os.matched_dn = @result[:matchedDN]
529-
elsif @result
530-
os.code = @result
528+
os.code = (result[:resultCode] || "").to_i
529+
os.error_message = result[:errorMessage]
530+
os.matched_dn = result[:matchedDN]
531+
elsif result
532+
os.code = result
531533
else
532534
os.code = 0
533535
end
@@ -649,7 +651,7 @@ def search(args = {})
649651
if return_result_set
650652
(!@result.nil? && @result.result_code == 0) ? result_set : nil
651653
else
652-
@result
654+
@result.success?
653655
end
654656
end
655657

@@ -723,7 +725,7 @@ def bind(auth = @auth)
723725
end
724726
end
725727

726-
@result
728+
@result.success?
727729
end
728730

729731
# #bind_as is for testing authentication credentials.
@@ -825,7 +827,7 @@ def add(args)
825827
conn.close if conn
826828
end
827829
end
828-
@result
830+
@result.success?
829831
end
830832

831833
# Modifies the attribute values of a particular entry on the LDAP
@@ -924,7 +926,7 @@ def modify(args)
924926
end
925927
end
926928

927-
@result
929+
@result.success?
928930
end
929931

930932
# Add a value to an attribute. Takes the full DN of the entry to modify,
@@ -995,7 +997,7 @@ def rename(args)
995997
conn.close if conn
996998
end
997999
end
998-
@result
1000+
@result.success?
9991001
end
10001002
alias_method :modify_rdn, :rename
10011003

@@ -1023,7 +1025,7 @@ def delete(args)
10231025
conn.close
10241026
end
10251027
end
1026-
@result
1028+
@result.success?
10271029
end
10281030

10291031
# Delete an entry from the LDAP directory along with all subordinate entries.

0 commit comments

Comments
 (0)