Converted LDAP#bind to return T/F and added LDAP::get_operation_result
to retrieve extended error information.
This commit is contained in:
parent
4bc667ffb2
commit
0117d386c0
1 changed files with 26 additions and 3 deletions
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
|
|
||||||
require 'socket'
|
require 'socket'
|
||||||
|
require 'ostruct'
|
||||||
require 'net/ber'
|
require 'net/ber'
|
||||||
require 'net/ldap/pdu'
|
require 'net/ldap/pdu'
|
||||||
require 'net/ldap/filter'
|
require 'net/ldap/filter'
|
||||||
|
@ -141,6 +142,27 @@ module Net
|
||||||
ldap.open {|ldap1| yield ldap1 }
|
ldap.open {|ldap1| yield ldap1 }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This method will return a meaningful result any time after
|
||||||
|
# a protocol operation (bind, search, add, modify, rename, delete)
|
||||||
|
# has completed.
|
||||||
|
# It returns an OpenStruct containing an LDAP result code (0 means success),
|
||||||
|
# and a human-readable string.
|
||||||
|
# unless ldap.bind
|
||||||
|
# puts "Result: #{ldap.get_operation_result.code}"
|
||||||
|
# puts "Message: #{ldap.get_operation_result.message}"
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
def get_operation_result
|
||||||
|
os = OpenStruct.new
|
||||||
|
if @result
|
||||||
|
os.code = @result
|
||||||
|
else
|
||||||
|
os.code = 0
|
||||||
|
end
|
||||||
|
os.message = LDAP.result2string( os.code )
|
||||||
|
os
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# This method opens a network connection to the server and then
|
# This method opens a network connection to the server and then
|
||||||
# passes self to the caller-supplied block. The connection is
|
# passes self to the caller-supplied block. The connection is
|
||||||
|
@ -206,13 +228,14 @@ module Net
|
||||||
#
|
#
|
||||||
def bind
|
def bind
|
||||||
if @open_connection
|
if @open_connection
|
||||||
@open_connection.bind @auth
|
@result = @open_connection.bind @auth
|
||||||
else
|
else
|
||||||
conn = Connection.new( :host => @host, :port => @port )
|
conn = Connection.new( :host => @host, :port => @port )
|
||||||
result = conn.bind @auth
|
@result = conn.bind @auth
|
||||||
conn.close
|
conn.close
|
||||||
result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@result == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Reference in a new issue