@@ -510,9 +510,17 @@ def LDAP::open args
510510 # puts "Message: #{ldap.get_operation_result.message}"
511511 # end
512512 #
513+ #--
514+ # Modified the implementation, 20Mar07. We might get a hash of LDAP response codes
515+ # instead of a simple numeric code.
516+ #
513517 def get_operation_result
514518 os = OpenStruct . new
515- if @result
519+ if @result . is_a? ( Hash )
520+ os . code = ( @result [ :resultCode ] || "" ) . to_i
521+ os . error_message = @result [ :errorMessage ]
522+ os . matched_dn = @result [ :matchedDN ]
523+ elsif @result
516524 os . code = @result
517525 else
518526 os . code = 0
@@ -802,6 +810,9 @@ def bind_as args={}
802810 # Net::LDAP.open (:host => host) do |ldap|
803811 # ldap.add( :dn => dn, :attributes => attr )
804812 # end
813+ #--
814+ # Provisional modification: Connection#add returns a full hash with LDAP status values,
815+ # instead of the simple result number we're used to getting.
805816 #
806817 def add args
807818 if @open_connection
@@ -1421,6 +1432,10 @@ def modify args
14211432 #--
14221433 # add
14231434 # TODO, need to support a time limit, in case the server fails to respond.
1435+ # Unlike other operation-methods in this class, we return a result hash rather
1436+ # than a simple result number. This is experimental, and eventually we'll want
1437+ # to do this with all the others. The point is to have access to the error message
1438+ # and the matched-DN returned by the server.
14241439 #
14251440 def add args
14261441 add_dn = args [ :dn ] or raise LdapError . new ( "Unable to add empty DN" )
@@ -1434,7 +1449,7 @@ def add args
14341449 @conn . write pkt
14351450
14361451 ( be = @conn . read_ber ( AsnSyntax ) ) && ( pdu = LdapPdu . new ( be ) ) && ( pdu . app_tag == 9 ) or raise LdapError . new ( "response missing or invalid" )
1437- pdu . result_code
1452+ pdu . result
14381453 end
14391454
14401455
0 commit comments