@@ -308,6 +308,7 @@ class LdapError < StandardError; end
308
308
DefaultPort = 389
309
309
DefaultAuth = { :method => :anonymous }
310
310
DefaultTreebase = "dc=com"
311
+ DefaultForceNoPage = false
311
312
312
313
StartTlsOid = "1.3.6.1.4.1.1466.20037"
313
314
@@ -370,6 +371,8 @@ def self.result2string(code) #:nodoc:
370
371
# specifying the Hash {:method => :simple_tls}. There is a fairly large
371
372
# range of potential values that may be given for this parameter. See
372
373
# #encryption for details.
374
+ # * :force_no_page => Set to true to prevent paged results even if your
375
+ # server says it supports them. This is a fix for MS Active Directory
373
376
#
374
377
# Instantiating a Net::LDAP object does <i>not</i> result in network
375
378
# traffic to the LDAP server. It simply stores the connection and binding
@@ -380,6 +383,7 @@ def initialize(args = {})
380
383
@verbose = false # Make this configurable with a switch on the class.
381
384
@auth = args [ :auth ] || DefaultAuth
382
385
@base = args [ :base ] || DefaultTreebase
386
+ @force_no_page = args [ :force_no_page ] || DefaultForceNoPage
383
387
encryption args [ :encryption ] # may be nil
384
388
385
389
if pr = @auth [ :password ] and pr . respond_to? ( :call )
@@ -1092,6 +1096,10 @@ def search_subschema_entry
1092
1096
# MUST refactor the root_dse call out.
1093
1097
#++
1094
1098
def paged_searches_supported?
1099
+ # active directory returns that it supports paged results. However
1100
+ # it returns binary data in the rfc2696_cookie which throws an
1101
+ # encoding exception breaking searching.
1102
+ return false if @force_no_page
1095
1103
@server_caps ||= search_root_dse
1096
1104
@server_caps [ :supportedcontrol ] . include? ( Net ::LDAP ::LdapControls ::PagedResults )
1097
1105
end
@@ -1387,6 +1395,10 @@ def search(args = {})
1387
1395
search_attributes . to_ber_sequence
1388
1396
] . to_ber_appsequence ( 3 )
1389
1397
1398
+ # rfc2696_cookie sometimes contains binary data from Microsoft Active Directory
1399
+ # this breaks when calling to_ber. (Can't force binary data to UTF-8)
1400
+ # we have to disable paging (even though server supports it) to get around this...
1401
+
1390
1402
controls = [ ]
1391
1403
controls <<
1392
1404
[
0 commit comments