aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Beck <simon.beck@vshn.ch>2022-02-09 10:36:04 +0100
committerGitea <gitea@fake.local>2022-02-14 12:13:31 +0100
commit9ce0d22c99472534838c1afe7c6dffdd0aa659a8 (patch)
tree014ccdfa0d1f2c77c056a854b5cb05cd9182da68
parentf05e41c9aad83f3d45aff620a739a116c32b4c47 (diff)
downloadbottin-9ce0d22c99472534838c1afe7c6dffdd0aa659a8.tar.gz
bottin-9ce0d22c99472534838c1afe7c6dffdd0aa659a8.zip
Fix wrong handling of multi value attributes
While ldapsearch doesn't seem to mind, apps like keycloak seem to have issues with adding multiple attributes with different values. While the resulting ldif in ldapsearch is indistinguishable there seems to be a slight different on the protocol level. If adding multiple attributes with the same name and different values, keycloak will only see the last entry. But adding a single attribute a slice of values is seems to handle it correctly.
-rw-r--r--read.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/read.go b/read.go
index 06e54b2..ef6df63 100644
--- a/read.go
+++ b/read.go
@@ -213,10 +213,11 @@ func (server *Server) handleSearchInternal(state *State, w ldap.ResponseWriter,
continue
}
// Send result
+ resultVals := []message.AttributeValue{}
for _, v := range val {
- e.AddAttribute(message.AttributeDescription(attr),
- message.AttributeValue(v))
+ resultVals = append(resultVals, message.AttributeValue(v))
}
+ e.AddAttribute(message.AttributeDescription(attr), resultVals...)
}
w.Write(e)
}