Skip to content

Commit 0564094

Browse files
doitianprathe
authored andcommitted
Do not add controls when it is empty. Fixed #17
Some LDAP servers, such as ApacheDS, consider as invalid protocol, if controls is an empty array.
1 parent 6bb9fa6 commit 0564094

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/net/ldap.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,9 +1394,9 @@ def search(args = {})
13941394
false.to_ber,
13951395
rfc2696_cookie.map{ |v| v.to_ber}.to_ber_sequence.to_s.to_ber
13961396
].to_ber_sequence if paged_searches_supported
1397-
controls = controls.to_ber_contextspecific(0)
1397+
controls = controls.empty? ? nil : controls.to_ber_contextspecific(0)
13981398

1399-
pkt = [next_msgid.to_ber, request, controls].to_ber_sequence
1399+
pkt = [next_msgid.to_ber, request, controls].compact.to_ber_sequence
14001400
@conn.write pkt
14011401

14021402
result_code = 0

0 commit comments

Comments
 (0)