Skip to content

Commit

Permalink
[v11] Fetch and buffer all entries from LDAP search (#19002)
Browse files Browse the repository at this point in the history
  • Loading branch information
Łukasz Kozłowski committed Dec 21, 2022
1 parent 5b0569d commit 059925a
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 059925a

Please sign in to comment.