From 63a19a13815aa380519c618d9c6b15a9160987a8 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 9 Dec 2021 20:55:51 +0100 Subject: [PATCH] outposts/ldap: fix searches with mixed casing Signed-off-by: Jens Langhammer --- internal/outpost/ldap/search.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/outpost/ldap/search.go b/internal/outpost/ldap/search.go index 99ad7b142..d1ea7c8b0 100644 --- a/internal/outpost/ldap/search.go +++ b/internal/outpost/ldap/search.go @@ -3,6 +3,7 @@ package ldap import ( "errors" "net" + "strings" "github.com/getsentry/sentry-go" goldap "github.com/go-ldap/ldap/v3" @@ -41,13 +42,13 @@ func (ls *LDAPServer) Search(bindDN string, searchReq ldap.SearchRequest, conn n if searchReq.BaseDN == "" { return ldap.ServerSearchResult{ResultCode: ldap.LDAPResultSuccess}, nil } - bd, err := goldap.ParseDN(searchReq.BaseDN) + bd, err := goldap.ParseDN(strings.ToLower(searchReq.BaseDN)) if err != nil { req.Log().WithError(err).Info("failed to parse basedn") return ldap.ServerSearchResult{ResultCode: ldap.LDAPResultOperationsError}, errors.New("invalid DN") } for _, provider := range ls.providers { - providerBase, _ := goldap.ParseDN(provider.BaseDN) + providerBase, _ := goldap.ParseDN(strings.ToLower(provider.BaseDN)) if providerBase.AncestorOf(bd) || providerBase.Equal(bd) { return provider.searcher.Search(req) }