diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-12 15:14:58 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-12 15:14:58 +0100 |
commit | 8ca2d399710195c5045c4a7db02e3c867bd4e87e (patch) | |
tree | dad8507b37608f753f459f4fe55dc634dc38426f | |
parent | e52a1f74a38cad3df083885aa8860a870a131cdb (diff) | |
download | bottin-8ca2d399710195c5045c4a7db02e3c867bd4e87e.tar.gz bottin-8ca2d399710195c5045c4a7db02e3c867bd4e87e.zip |
Optimize some kv.List requests to not list all children
-rw-r--r-- | main.go | 2 | ||||
-rw-r--r-- | read.go | 9 |
2 files changed, 8 insertions, 3 deletions
@@ -371,7 +371,7 @@ func (server *Server) objectExists(dn string) (bool, error) { return false, err } - data, _, err := server.kv.List(prefix+"/", nil) + data, _, err := server.kv.List(prefix+"/attribute=", nil) if err != nil { return false, err } @@ -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 { |