ruby-net-ldap icon indicating copy to clipboard operation
ruby-net-ldap copied to clipboard

Wrong paged result from search

Open cfbrobak opened this issue 12 years ago • 11 comments

Environment: Windows XP, Java 1.6.0_29, JRuby 1.6.7 and net-ldap 0.3.1. JRuby is running in Ruby 1.9 mode.

Scenario: Searching for computers in our Windows Active Directory.

As I understand it, if the search result contains more than 126 (hardcoded page size in net/ldap.rb) entries, which it always does in my case, the server returns a cookie indicating a paged result (RFC 2696). The cookie should be sent back by the client when requesting more entries from the result. This does not seem to work. The result is always 126 bigger than it should be and those 126 seem to be duplicates of some already in the result.

Another problem: If the result contains more than 1000 entries a "Size Limit Exceeded" error is returned.

My guess is that net-ldap somehow changes the cookie before sending it back to the server.

If I switch to net-ldap 0.2.2, it seems to work as it should.

cfbrobak avatar Apr 10 '12 15:04 cfbrobak

I've also experienced this issue. an encoding exception occurs on the 127th request.

GirlBossRush avatar Aug 08 '12 17:08 GirlBossRush

I had similar problems, the paging cookie got corrupted by the UTF-8 encoding. The master branch seems to behave better than 0.3.1.

normelton avatar Oct 02 '12 18:10 normelton

I'm seeing something similar to this (duplicate results, but not all are duplicated) querying AD (Server 2008). Ruby 1.9.3p125 (2012-02-16) [i386-mingw32] with 0.3.1 exhibits the problem (windows 7). Ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-linux] with 0.3.1 does not.

blackpoplar avatar Oct 18 '12 14:10 blackpoplar

I had similar problems, too. My case might have over 5000 entity in AD server. I alway fetch '1126' entries from AD on 0.3.1. (Even I manual patched net-ldap by #44 ). If I switch to 0.2.2, the problem had gone.

chy168 avatar Mar 15 '13 07:03 chy168

It's best to abandon this gem. The project is not being maintained. I ended up using Python's LDAP libraries to solve the issue. Not ideal, but it gets the job done.

On Mar 15, 2013, at 3:08 AM, Hung-Yen [email protected] wrote:

I had similar problems, too. My case might have over 5000 entity in AD server. I alway fetch '1126' entries from AD on 0.3.1. (Even I manual patched net-ldap by #44 ). If I switch to 0.2.2, the problem had gone.


Reply to this email directly or view it on GitHub.

GirlBossRush avatar Mar 15 '13 07:03 GirlBossRush

this is still an issue for me. Even though the page size is set to 126 and the possible result set is generally much larger than 1000 entries (I set the size to a very large number as I want the whole result set) the behaviour I'm seeing with AD is:

  • a first page containing 126 results
  • a 2nd page up until 1126 results
  • then Size Limit exceeded error

as if it was not actually doing any paging (126 results at a time).

In ruby there doesn't seem to be any other project as active as this one but this is a real blocker for us.

@jch can you please comment on this? I'm using master (8a18267) branch and seeing this behaviour...

saimonmoore avatar Nov 12 '15 10:11 saimonmoore

And I have just confirmed that 0.2.2 works fine (at least with paging)

saimonmoore avatar Nov 12 '15 10:11 saimonmoore

@saimonmoore thanks for bumping this thread and the helpful reproduction list. I wasn't a maintainer back around 0.2.2, so I'll need to take some time to dig into the differences. There's been a lot of changes since then, so it may be worth revisiting this from scratch as well.

It sounds like you have a good environment for reproducing this. Would you be interested in opening a PR to attempt to fix this? I'm not very familiar with AD and don't have a local setup, so it would speed up development if you got something started. I'm happy to code review and follow up.

cc @meastman also in case you're looking for something to hack on during downtime

jch avatar Nov 12 '15 18:11 jch

@jch basically it all started to break with the introduction of utf8 encoding...

I will try and see if I have more time to track down the exact change...

saimonmoore avatar Nov 12 '15 18:11 saimonmoore

Arrrgh, UTF8! :+1: to digging in.

jch avatar Nov 12 '15 18:11 jch

Encountering this issue described on StackOverflow. Weird behaviour because the problem is only seen when I invoke the code from Rails, not while I run it through a regular script.

arindam2 avatar May 03 '17 18:05 arindam2