MCPcopy Create free account
hub / github.com/Macmod/godap / executeSearch

Function executeSearch

tui/search.go:404–534  ·  view source on GitHub ↗
(overrideBaseDN string)

Source from the content-addressed store, hash-verified

402}
403
404func executeSearch(overrideBaseDN string) {
405 updateLog("Performing recursive query...", "yellow")
406
407 baseDN := overrideBaseDN
408 if baseDN == "" {
409 baseDN = searchBaseDN
410 }
411
412 rootNode := tview.NewTreeNode(baseDN).SetSelectable(true)
413 searchTreePanel.
414 SetRoot(rootNode).
415 SetCurrentNode(rootNode)
416
417 searchCache.Clear()
418 clear(searchLoadedDNs)
419
420 searchQuery := searchQueryPanel.GetText()
421
422 go func() {
423 runControl.Lock()
424 if running {
425 runControl.Unlock()
426 return
427 }
428 running = true
429 runControl.Unlock()
430
431 if searchQuery != "" && !strings.Contains(searchQuery, "(") {
432 searchQuery = fmt.Sprintf(
433 "(|(samAccountName=%s)(cn=%s)(ou=%s)(name=%s))",
434 searchQuery, searchQuery, searchQuery, searchQuery,
435 )
436 }
437
438 startTime := time.Now()
439
440 entries, err := lc.QueryWithAttrs(baseDN, searchQuery, searchScope, Deleted, parseAttrsList(searchAttrsList))
441 if err != nil {
442 handleLDAPError(err)
443 runControl.Lock()
444 running = false
445 runControl.Unlock()
446 return
447 }
448
449 duration := time.Since(startTime)
450
451 firstLeaf := true
452
453 for _, entry := range entries {
454 if entry.DN == baseDN {
455 // The result IS the root node itself.
456 // Set reference and reload attrs directly — SetCurrentNode won't
457 // fire ChangedFunc because rootNode is already the selected node.
458 app.QueueUpdateDraw(func() {
459 rootNode.SetReference(entry.DN)
460 rootNode.SetText(getNodeName(entry))
461 searchCache.Add(entry.DN, entry)

Callers 2

initSearchPageFunction · 0.85
searchQueryDoneHandlerFunction · 0.85

Calls 11

updateLogFunction · 0.85
parseAttrsListFunction · 0.85
handleLDAPErrorFunction · 0.85
getNodeNameFunction · 0.85
reloadSearchAttrsPanelFunction · 0.85
GetEntryColorFunction · 0.85
addToSearchHistoryFunction · 0.85
updateSearchHistoryPanelFunction · 0.85
ClearMethod · 0.80
QueryWithAttrsMethod · 0.80
AddMethod · 0.80

Tested by

no test coverage detected