Fix the base DN searches

This commit is contained in:
signaryk 2024-07-05 17:15:18 -05:00
parent 3c5e55b83e
commit 1802a16d8a

View file

@ -14,7 +14,7 @@ import (
) )
func (s *server) handleSearchDSE(w ldap.ResponseWriter, m *ldap.Message) { func (s *server) handleSearchDSE(w ldap.ResponseWriter, m *ldap.Message) {
nc := strings.Join(s.nc, ", ") nc := strings.Join(s.nc, ",")
e := ldap.NewSearchResultEntry("") e := ldap.NewSearchResultEntry("")
e.AddAttribute("vendorName", "NetAuth") 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) { func (s *server) handleBaseDnSearch(w ldap.ResponseWriter, m *ldap.Message) {
ctx := context.Background() nc := strings.Join(s.nc, ",")
s.l.Debug("Base DN search")
r := m.GetSearchRequest()
ents, err := s.c.GroupSearch(ctx, "Name:*") e := ldap.NewSearchResultEntry(strings.Join(s.nc, ","))
if err != nil { e.AddAttribute("vendorName", "NetAuth")
res := ldap.NewSearchResultDoneResponse(ldap.LDAPResultOperationsError) e.AddAttribute("vendorVersion", message.AttributeValue(buildinfo.Version))
res.SetDiagnosticMessage(err.Error()) e.AddAttribute("objectClass", "top", "extensibleObject")
w.Write(res) e.AddAttribute("supportedLDAPVersion", "3")
return e.AddAttribute("namingContexts", message.AttributeValue(nc))
} w.Write(e)
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)
} }
func (s *server) handleSearchEntities(w ldap.ResponseWriter, m *ldap.Message) { func (s *server) handleSearchEntities(w ldap.ResponseWriter, m *ldap.Message) {