Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

size limit causing problems #737

Closed
donraikes opened this issue Jun 7, 2021 · 8 comments
Closed

size limit causing problems #737

donraikes opened this issue Jun 7, 2021 · 8 comments

Comments

@donraikes
Copy link

Hello,
I am attempting to perform an ldap search using the following options:
var opts {
scope: "sub",
filter: (|(displayName=*${user}*)(mail=*${user}*)),
attributes: ["displayName", "mail", "title", "manager","orclcorpcostcenter","ou"],
sizeLimit: 1000
};

All works fine until the number of ldap responses exceeds the size limit.

For example if ${user} = "john" I don't know how many results that returns, but with size limit 1000, what I get back is an empty json object.

If I use any search criteria that returns less than the size limit set, I get all the data I want.

I am running an express.js server serving this data in a rest api.

@UziTech
Copy link
Member

UziTech commented Jun 8, 2021

Are you subscribed to the error event on the server or client? Do you get any errors?

It would be a lot easier for us to debug if you could share your code setting up the ldapjs client or server.

@donraikes
Copy link
Author

The express server is subscribed to the client error events (see server.txt) for my express server code.
I am now getting a different error which is causing my express server to fail any time an end point is accessed. It looks like there is some kind of connection reset happening (see server.log) for the errors.
server.txtf
server.log

@UziTech
Copy link
Member

UziTech commented Jun 8, 2021

this seems like an issue with your server. Are there any errors on your server when sizeLimit is sent?

It could also be that JSON.stringify is failing in your doSearch function and you aren't catching the error. You could try logging entry.object on searchEntry to see what it is returning.

@donraikes
Copy link
Author

Ok so I added a console.log(entry.object) and all seems to be working until I run into a timeout exceeded error.

I guess I need to set the timelimit in my search options.

@donraikes
Copy link
Author

I modified my ldap.createClient to include timeout:5000 and connectTimeout:1000.
Now when I run my test query, I am getting the size limit exceeded error.

Is there a way to retrieve just the first 100 results without throwing an error?

@UziTech
Copy link
Member

UziTech commented Jun 8, 2021

according to #313 (comment) it could be an issue where your server is limiting the number of results because you aren't binding to a user.

@jsumners
Copy link
Member

jsumners commented Jun 9, 2021

We have tests specifically around size limits --

tap.test('search sizeLimit', function (t) {
t.test('over limit', function (t2) {
t.context.client.search('cn=sizelimit', {}, function (err, res) {
t2.error(err)
res.on('error', function (error) {
t2.equal(error.name, 'SizeLimitExceededError')
t2.end()
})
})
})
t.test('under limit', function (t2) {
const limit = 100
t.context.client.search('cn=sizelimit', { sizeLimit: limit }, function (err, res) {
t2.error(err)
let count = 0
res.on('searchEntry', function () {
count++
})
res.on('end', function () {
t2.pass()
t2.equal(count, limit)
t2.end()
})
res.on('error', t2.error.bind(t))
})
})
t.end()
})

If they are not sufficient, feel free to add some to our integration tests -- https://github.com/ldapjs/node-ldapjs/blob/3430f05d91bc152b18febe1f04665c8aea0faf11/test-integration/client/issues.test.js

@jsumners
Copy link
Member

👋

On February 22, 2023, we released version 3 of this library. As a result, we are closing this issue/pull request.

Please see issue #839 for more information, including how to proceed if you feel this closure is in error.

@ldapjs ldapjs locked as resolved and limited conversation to collaborators Feb 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants