From 756529b3ae7b62473edc644bd9cd0c07b0ddf212 Mon Sep 17 00:00:00 2001 From: Jamstah Date: Wed, 5 Jan 2011 14:07:36 +0000 Subject: [PATCH] Only add the paging control if the server supports it. This is partly to work around a bug where a server will not allow all users to page, and will return insufficient access instead of ignoring the control. --- lib/net/ldap.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index eb63414..0d83851 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -1386,14 +1386,15 @@ class Net::LDAP::Connection #:nodoc: search_attributes.to_ber_sequence ].to_ber_appsequence(3) - controls = [ + controls = [] + controls << [ Net::LDAP::LdapControls::PagedResults.to_ber, # Criticality MUST be false to interoperate with normal LDAPs. false.to_ber, rfc2696_cookie.map{ |v| v.to_ber}.to_ber_sequence.to_s.to_ber - ].to_ber_sequence - ].to_ber_contextspecific(0) + ].to_ber_sequence if paged_searches_supported + controls = controls.to_ber_contextspecific(0) pkt = [next_msgid.to_ber, request, controls].to_ber_sequence @conn.write pkt