From 1802a16d8a7f06352c578c01050561c1b24ee5d1 Mon Sep 17 00:00:00 2001 From: William Luke Date: Fri, 5 Jul 2024 17:15:18 -0500 Subject: [PATCH] Fix the base DN searches --- internal/ldap/search.go | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/internal/ldap/search.go b/internal/ldap/search.go index ae805eb..457d6ed 100644 --- a/internal/ldap/search.go +++ b/internal/ldap/search.go @@ -14,7 +14,7 @@ import ( ) func (s *server) handleSearchDSE(w ldap.ResponseWriter, m *ldap.Message) { - nc := strings.Join(s.nc, ", ") + nc := strings.Join(s.nc, ",") e := ldap.NewSearchResultEntry("") e.AddAttribute("vendorName", "NetAuth") @@ -29,33 +29,15 @@ func (s *server) handleSearchDSE(w ldap.ResponseWriter, m *ldap.Message) { } func (s *server) handleBaseDnSearch(w ldap.ResponseWriter, m *ldap.Message) { - ctx := context.Background() - s.l.Debug("Base DN search") - r := m.GetSearchRequest() + nc := strings.Join(s.nc, ",") - ents, err := s.c.GroupSearch(ctx, "Name:*") - if err != nil { - res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultOperationsError) - res.SetDiagnosticMessage(err.Error()) - w.Write(res) - return - } - - for i := range ents { - e, err := s.groupSearchResult(ctx, ents[i], r.BaseObject(), r.Attributes()) - if err != nil { - res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultOperationsError) - res.SetDiagnosticMessage(err.Error()) - w.Write(res) - return - } - w.Write(e) - } - - s.l.Debug("Entities", "res", ents) - - res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultSuccess) - w.Write(res) + e := ldap.NewSearchResultEntry(strings.Join(s.nc, ",")) + e.AddAttribute("vendorName", "NetAuth") + e.AddAttribute("vendorVersion", message.AttributeValue(buildinfo.Version)) + e.AddAttribute("objectClass", "top", "extensibleObject") + e.AddAttribute("supportedLDAPVersion", "3") + e.AddAttribute("namingContexts", message.AttributeValue(nc)) + w.Write(e) } func (s *server) handleSearchEntities(w ldap.ResponseWriter, m *ldap.Message) {