(rootDN string, searchFilter string)
| 940 | } |
| 941 | |
| 942 | func renderPartialTree(rootDN string, searchFilter string) *tview.TreeNode { |
| 943 | rootEntry, err := lc.QueryWithAttrs(rootDN, "(objectClass=*)", ldap.ScopeBaseObject, Deleted, parseAttrsList(explorerAttrsList)) |
| 944 | if err != nil { |
| 945 | handleLDAPError(err) |
| 946 | return nil |
| 947 | } |
| 948 | |
| 949 | if len(rootEntry) != 1 { |
| 950 | updateLog("Root entry not found.", "red") |
| 951 | return nil |
| 952 | } |
| 953 | |
| 954 | explorerCache.Add(rootDN, rootEntry[0]) |
| 955 | |
| 956 | rootNodeName := getNodeName(rootEntry[0]) |
| 957 | |
| 958 | rootNode = tview.NewTreeNode(rootNodeName). |
| 959 | SetReference(rootDN). |
| 960 | SetSelectable(true) |
| 961 | |
| 962 | if rootDN == "" { |
| 963 | return rootNode |
| 964 | } |
| 965 | |
| 966 | var rootEntries []*ldap.Entry |
| 967 | rootEntries, err = lc.QueryWithAttrs(rootDN, searchFilter, ldap.ScopeSingleLevel, Deleted, parseAttrsList(explorerAttrsList)) |
| 968 | if err != nil { |
| 969 | handleLDAPError(err) |
| 970 | return nil |
| 971 | } |
| 972 | |
| 973 | // Sort results to guarantee stable view |
| 974 | sort.Slice(rootEntries, func(i int, j int) bool { |
| 975 | return getName(rootEntries[i]) < getName(rootEntries[j]) |
| 976 | }) |
| 977 | |
| 978 | for _, entry := range rootEntries { |
| 979 | node := createTreeNodeFromEntry(entry) |
| 980 | if node != nil { |
| 981 | rootNode.AddChild(node) |
| 982 | } |
| 983 | } |
| 984 | |
| 985 | return rootNode |
| 986 | } |
| 987 | |
| 988 | func reloadExplorerPage() { |
| 989 | explorerAttrsPanel.Clear() |
no test coverage detected