Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v10] Fetch and buffer all entries from LDAP search (#19002) #19534

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/srv/desktop/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ import (
"github.com/gravitational/trace"
)

const (
// searchPageSize is desired page size for LDAP search. In Active Directory the default search size limit is 1000 entries,
// so in most cases the 1000 search page size will result in the optimal amount of requests made to
// LDAP server.
searchPageSize = 1000
)

// Note: if you want to browse LDAP on the Windows machine, run ADSIEdit.msc.
type ldapClient struct {
cfg LDAPConfig
Expand Down Expand Up @@ -66,7 +73,7 @@ func (c *ldapClient) readWithFilter(dn string, filter string, attrs []string) ([
)
c.mu.Lock()
defer c.mu.Unlock()
res, err := c.client.Search(req)
res, err := c.client.SearchWithPaging(req, searchPageSize)
if ldap.IsErrorWithCode(err, ldap.ErrorNetwork) {
return nil, trace.ConnectionProblem(err, "fetching LDAP object %q", dn)
} else if err != nil {
Expand Down