From 8ca2d399710195c5045c4a7db02e3c867bd4e87e Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 12 Feb 2020 15:14:58 +0100 Subject: Optimize some kv.List requests to not list all children --- read.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'read.go') diff --git a/read.go b/read.go index 43833e8..9af9dbd 100644 --- a/read.go +++ b/read.go @@ -103,8 +103,13 @@ func (server *Server) handleSearchInternal(state *State, w ldap.ResponseWriter, if err != nil { return ldap.LDAPResultInvalidDNSyntax, err } + if r.Scope() == message.SearchRequestScopeBaseObject { + basePath += "/attribute=" + } else { + basePath += "/" + } - data, _, err := server.kv.List(basePath+"/", nil) + data, _, err := server.kv.List(basePath, nil) if err != nil { return ldap.LDAPResultOperationsError, err } @@ -114,7 +119,7 @@ func (server *Server) handleSearchInternal(state *State, w ldap.ResponseWriter, return ldap.LDAPResultOperationsError, err } - server.logger.Tracef("in %s: %#v", basePath+"/", data) + server.logger.Tracef("in %s: %#v", basePath, data) server.logger.Tracef("%#v", entries) for dn, entry := range entries { -- cgit v1.2.3