Skip to content

Commit ebbb6f5

Browse files
author
Andres Rodriguez
committed
Allow ldap.get_operation_result to fill custom error messages generated by the LDAP server on add/modify/delete
1 parent 6bb9fa6 commit ebbb6f5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/net/ldap.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ def self.open(args)
516516
#++
517517
def get_operation_result
518518
os = OpenStruct.new
519+
519520
if @result.is_a?(Hash)
520521
# We might get a hash of LDAP response codes instead of a simple
521522
# numeric code.
@@ -822,7 +823,7 @@ def add(args)
822823
conn.close if conn
823824
end
824825
end
825-
@result == 0
826+
@result[:resultCode] == 0
826827
end
827828

828829
# Modifies the attribute values of a particular entry on the LDAP
@@ -920,7 +921,7 @@ def modify(args)
920921
conn.close if conn
921922
end
922923
end
923-
@result == 0
924+
@result[:resultCode] == 0
924925
end
925926

926927
# Add a value to an attribute. Takes the full DN of the entry to modify,
@@ -991,7 +992,7 @@ def rename(args)
991992
conn.close if conn
992993
end
993994
end
994-
@result == 0
995+
@result[:resultCode] == 0
995996
end
996997
alias_method :modify_rdn, :rename
997998

@@ -1019,7 +1020,7 @@ def delete(args)
10191020
conn.close
10201021
end
10211022
end
1022-
@result == 0
1023+
@result[:resultCode] == 0
10231024
end
10241025

10251026
# This method is experimental and subject to change. Return the rootDSE
@@ -1494,7 +1495,7 @@ def modify(args)
14941495
@conn.write pkt
14951496

14961497
(be = @conn.read_ber(Net::LDAP::AsnSyntax)) && (pdu = Net::LDAP::PDU.new(be)) && (pdu.app_tag == 7) or raise Net::LDAP::LdapError, "response missing or invalid"
1497-
pdu.result_code
1498+
pdu.result
14981499
end
14991500

15001501
#--
@@ -1516,7 +1517,7 @@ def add(args)
15161517
@conn.write pkt
15171518

15181519
(be = @conn.read_ber(Net::LDAP::AsnSyntax)) && (pdu = Net::LDAP::PDU.new(be)) && (pdu.app_tag == 9) or raise Net::LDAP::LdapError, "response missing or invalid"
1519-
pdu.result_code
1520+
pdu.result
15201521
end
15211522

15221523
#--
@@ -1537,7 +1538,7 @@ def rename args
15371538
(be = @conn.read_ber(Net::LDAP::AsnSyntax)) &&
15381539
(pdu = Net::LDAP::PDU.new( be )) && (pdu.app_tag == 13) or
15391540
raise Net::LDAP::LdapError.new( "response missing or invalid" )
1540-
pdu.result_code
1541+
pdu.result
15411542
end
15421543

15431544
#--
@@ -1551,6 +1552,6 @@ def delete(args)
15511552
@conn.write pkt
15521553

15531554
(be = @conn.read_ber(Net::LDAP::AsnSyntax)) && (pdu = Net::LDAP::PDU.new(be)) && (pdu.app_tag == 11) or raise Net::LDAP::LdapError, "response missing or invalid"
1554-
pdu.result_code
1555+
pdu.result
15551556
end
15561557
end # class Connection

0 commit comments

Comments
 (0)