Implement base DN search that's basically group search
This commit is contained in:
parent
50183c2cba
commit
3c5e55b83e
|
@ -91,11 +91,11 @@ func (s *server) SetDomain(domain string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register routes that are dependent on the namingConvention
|
// Register routes that are dependent on the namingConvention
|
||||||
s.routes.Search(s.handleSearchDSE).
|
s.routes.Search(s.handleBaseDnSearch).
|
||||||
BaseDn(strings.Join(s.nc, ",")).
|
BaseDn(strings.Join(s.nc, ",")).
|
||||||
Scope(ldap.SearchRequestScopeBaseObject).
|
Scope(ldap.SearchRequestScopeBaseObject).
|
||||||
Filter("(objectclass=*)").
|
Filter("(objectclass=*)").
|
||||||
Label("Search - ROOT DSE")
|
Label("Search - Base DN")
|
||||||
|
|
||||||
entitySearchDN := "ou=entities," + strings.Join(s.nc, ",")
|
entitySearchDN := "ou=entities," + strings.Join(s.nc, ",")
|
||||||
s.routes.Search(s.handleSearchEntities).
|
s.routes.Search(s.handleSearchEntities).
|
||||||
|
|
|
@ -28,6 +28,36 @@ func (s *server) handleSearchDSE(w ldap.ResponseWriter, m *ldap.Message) {
|
||||||
w.Write(res)
|
w.Write(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *server) handleBaseDnSearch(w ldap.ResponseWriter, m *ldap.Message) {
|
||||||
|
ctx := context.Background()
|
||||||
|
s.l.Debug("Base DN search")
|
||||||
|
r := m.GetSearchRequest()
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *server) handleSearchEntities(w ldap.ResponseWriter, m *ldap.Message) {
|
func (s *server) handleSearchEntities(w ldap.ResponseWriter, m *ldap.Message) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
s.l.Debug("Search Entities")
|
s.l.Debug("Search Entities")
|
||||||
|
|
Loading…
Reference in a new issue