Skip to content

Commit 8acd4ac

Browse files
author
Rory O'Connell
committed
Merge pull request #39 from aspgems/master
Changed back return values in API methods to match what documentation says
2 parents 8ddb2d7 + d6aa24e commit 8acd4ac

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
@@ -523,15 +523,17 @@ def self.open(args)
523523
# response codes instead of a simple numeric code.
524524
#++
525525
def get_operation_result
526+
result = @result
527+
result = result.result if result.is_a?(Net::LDAP::PDU)
526528
os = OpenStruct.new
527-
if @result.is_a?(Hash)
529+
if result.is_a?(Hash)
528530
# We might get a hash of LDAP response codes instead of a simple
529531
# numeric code.
530-
os.code = (@result[:resultCode] || "").to_i
531-
os.error_message = @result[:errorMessage]
532-
os.matched_dn = @result[:matchedDN]
533-
elsif @result
534-
os.code = @result
532+
os.code = (result[:resultCode] || "").to_i
533+
os.error_message = result[:errorMessage]
534+
os.matched_dn = result[:matchedDN]
535+
elsif result
536+
os.code = result
535537
else
536538
os.code = 0
537539
end
@@ -653,7 +655,7 @@ def search(args = {})
653655
if return_result_set
654656
(!@result.nil? && @result.result_code == 0) ? result_set : nil
655657
else
656-
@result
658+
@result.success?
657659
end
658660
end
659661

@@ -727,7 +729,7 @@ def bind(auth = @auth)
727729
end
728730
end
729731

730-
@result
732+
@result.success?
731733
end
732734

733735
# #bind_as is for testing authentication credentials.
@@ -829,7 +831,7 @@ def add(args)
829831
conn.close if conn
830832
end
831833
end
832-
@result
834+
@result.success?
833835
end
834836

835837
# Modifies the attribute values of a particular entry on the LDAP
@@ -928,7 +930,7 @@ def modify(args)
928930
end
929931
end
930932

931-
@result
933+
@result.success?
932934
end
933935

934936
# Add a value to an attribute. Takes the full DN of the entry to modify,
@@ -999,7 +1001,7 @@ def rename(args)
9991001
conn.close if conn
10001002
end
10011003
end
1002-
@result
1004+
@result.success?
10031005
end
10041006
alias_method :modify_rdn, :rename
10051007

@@ -1027,7 +1029,7 @@ def delete(args)
10271029
conn.close
10281030
end
10291031
end
1030-
@result
1032+
@result.success?
10311033
end
10321034

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

0 commit comments

Comments
 (0)