Permalink
Browse files

Changed back return values in API methods to match what documentation…

… says
  • Loading branch information...
1 parent 51597ea commit d6aa24ebea9367cacaa2f7b4f5fc23d2227ede8b @frsantos frsantos committed Apr 18, 2012
Showing with 14 additions and 12 deletions.
  1. +14 −12 lib/net/ldap.rb
View
@@ -519,15 +519,17 @@ def self.open(args)
# response codes instead of a simple numeric code.
#++
def get_operation_result
+ result = @result
+ result = result.result if result.is_a?(Net::LDAP::PDU)
os = OpenStruct.new
- if @result.is_a?(Hash)
+ if result.is_a?(Hash)
# We might get a hash of LDAP response codes instead of a simple
# numeric code.
- os.code = (@result[:resultCode] || "").to_i
- os.error_message = @result[:errorMessage]
- os.matched_dn = @result[:matchedDN]
- elsif @result
- os.code = @result
+ os.code = (result[:resultCode] || "").to_i
+ os.error_message = result[:errorMessage]
+ os.matched_dn = result[:matchedDN]
+ elsif result
+ os.code = result
else
os.code = 0
end
@@ -649,7 +651,7 @@ def search(args = {})
if return_result_set
(!@result.nil? && @result.result_code == 0) ? result_set : nil
else
- @result
+ @result.success?
end
end
@@ -723,7 +725,7 @@ def bind(auth = @auth)
end
end
- @result
+ @result.success?
end
# #bind_as is for testing authentication credentials.
@@ -825,7 +827,7 @@ def add(args)
conn.close if conn
end
end
- @result
+ @result.success?
end
# Modifies the attribute values of a particular entry on the LDAP
@@ -924,7 +926,7 @@ def modify(args)
end
end
- @result
+ @result.success?
end
# Add a value to an attribute. Takes the full DN of the entry to modify,
@@ -995,7 +997,7 @@ def rename(args)
conn.close if conn
end
end
- @result
+ @result.success?
end
alias_method :modify_rdn, :rename
@@ -1023,7 +1025,7 @@ def delete(args)
conn.close
end
end
- @result
+ @result.success?
end
# Delete an entry from the LDAP directory along with all subordinate entries.

3 comments on commit d6aa24e

Collaborator

satoryu replied Mar 12, 2013

@frsantos , Why did you change?
This change affects other gems which depends on net-ldap.

Contributor

frsantos replied Mar 12, 2013

Commit 2763040 broke some API methods (like bind_as) and the contract between what their documentation says to return (a boolean) and the actual returned value (a PDU).

This commit reverted the changes in those API methods to return what its documentation said.

Collaborator

satoryu replied Mar 12, 2013

I got it. Thanks 😄

Please sign in to comment.