Optimize some kv.List requests to not list all children
This commit is contained in:
parent
e52a1f74a3
commit
8ca2d39971
2 changed files with 8 additions and 3 deletions
2
main.go
2
main.go
|
@ -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
|
||||
}
|
||||
|
|
9
read.go
9
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 {
|
||||
|
|
Loading…
Reference in a new issue