From 44d8cee507e83de10d6b6640a48aac331dea9133 Mon Sep 17 00:00:00 2001 From: Michael Aldridge Date: Sun, 8 Nov 2020 19:33:21 -0800 Subject: [PATCH] internal/ldap: Correctly handle multi-valued attributes --- internal/ldap/search.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/ldap/search.go b/internal/ldap/search.go index 73f3840..5774258 100644 --- a/internal/ldap/search.go +++ b/internal/ldap/search.go @@ -85,10 +85,12 @@ func (s *server) entitySearchResult(ctx context.Context, e *pb.Entity, dn messag return res, err } + memberOf := []message.AttributeValue{} for i := range grps { g := "cn=" + grps[i].GetName() + ",ou=groups," + strings.Join(s.nc, ",") - res.AddAttribute("memberOf", message.AttributeValue(g)) + memberOf = append(memberOf, message.AttributeValue(g)) } + res.AddAttribute("memberOf", memberOf...) return res, nil } @@ -149,10 +151,12 @@ func (s *server) groupSearchResult(ctx context.Context, g *pb.Group, dn message. return res, err } + memberList := []message.AttributeValue{} for i := range members { g := "uid=" + members[i].GetID() + ",ou=entities," + strings.Join(s.nc, ",") - res.AddAttribute("member", message.AttributeValue(g)) + memberList = append(memberList, message.AttributeValue(g)) } + res.AddAttribute("member", memberList...) return res, nil }