go-ldap / ldap

Basic LDAP v3 functionality for the GO programming language.
Other
2.25k stars 355 forks source link

Question - How to limit the number of results #431

Closed abolinhas closed 9 months ago

abolinhas commented 1 year ago

Hi I have a big active directory with a lot of entries, what i prented to achive with go-ldap is to retrive only the first 50 results. I already try the size limit option or paging but always return all results. Anyone can help me to limit the number of results per search? Best regards

cpuschma commented 1 year ago

Hi,

SizeLimit should do the trick usually. Are you querying using SearchWithPaging or a normal search request? Additionally, you can reduce the search scope to one organizational unit and enumerate over them one by one if necessary until you hit your limit

VakarisZ commented 1 year ago

For me sizeLimit does nothing: image

VakarisZ commented 1 year ago

LdapSearch -z option does nothing also. I think this has something to do with the ldap setup, not a bug in this package

GuoFlight commented 9 months ago

I have the same problem.

cpuschma commented 9 months ago

I can replicate this issue, but it is not an implementation issue of the library. I analyzed the traffic with Wireshark and the SizeLimit attribute is correctly set and sent to the server.

I've created a patch and a PR to optionally enforce a size limit.

cpuschma commented 9 months ago

See #482