Implement (inefficiently) search scopes
This commit is contained in:
parent
d02bd17b16
commit
0402f7806a
2 changed files with 13 additions and 1 deletions
|
@ -12,7 +12,7 @@ job "directory" {
|
||||||
task "server" {
|
task "server" {
|
||||||
driver = "docker"
|
driver = "docker"
|
||||||
config {
|
config {
|
||||||
image = "lxpz/bottin_amd64:7"
|
image = "lxpz/bottin_amd64:8"
|
||||||
readonly_rootfs = true
|
readonly_rootfs = true
|
||||||
port_map {
|
port_map {
|
||||||
ldap_port = 389
|
ldap_port = 389
|
||||||
|
|
12
read.go
12
read.go
|
@ -97,6 +97,8 @@ func (server *Server) handleSearchInternal(state *State, w ldap.ResponseWriter,
|
||||||
return ldap.LDAPResultInsufficientAccessRights, fmt.Errorf("Please specify a base object on which you have read rights")
|
return ldap.LDAPResultInsufficientAccessRights, fmt.Errorf("Please specify a base object on which you have read rights")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
baseObjectLevel := len(strings.Split(baseObject, ","))
|
||||||
|
|
||||||
basePath, err := dnToConsul(baseObject)
|
basePath, err := dnToConsul(baseObject)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ldap.LDAPResultInvalidDNSyntax, err
|
return ldap.LDAPResultInvalidDNSyntax, err
|
||||||
|
@ -116,6 +118,16 @@ func (server *Server) handleSearchInternal(state *State, w ldap.ResponseWriter,
|
||||||
server.logger.Tracef("%#v", entries)
|
server.logger.Tracef("%#v", entries)
|
||||||
|
|
||||||
for dn, entry := range entries {
|
for dn, entry := range entries {
|
||||||
|
if r.Scope() == message.SearchRequestScopeBaseObject {
|
||||||
|
if dn != baseObject {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
} else if r.Scope() == message.SearchRequestSingleLevel {
|
||||||
|
objectLevel := len(strings.Split(dn, ","))
|
||||||
|
if objectLevel != baseObjectLevel + 1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
// Filter out if we don't match requested filter
|
// Filter out if we don't match requested filter
|
||||||
matched, err := applyFilter(entry, r.Filter())
|
matched, err := applyFilter(entry, r.Filter())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue