diff --git a/README.md b/README.md
index 2e9d3aa..b0a09ef 100644
--- a/README.md
+++ b/README.md
@@ -144,7 +144,7 @@ You can also change the address of your proxy using the `l` keybinding.
| r | Explorer panel | Reload the attributes and children of the selected object |
| Ctrl + n | Explorer panel | Create a new object under the selected object |
| Ctrl + s | Explorer panel | Export all loaded nodes in the selected subtree into a JSON file |
-| Ctrl + p | Explorer panel | Change the password of the selected user or computer account |
+| Ctrl + p | Explorer panel | Change the password of the selected user or computer account (requires TLS) |
| Ctrl + a | Explorer panel | Update the userAccountControl of the object interactively |
| Ctrl + l | Explorer panel | Move the selected object to another location |
| Delete | Explorer panel | Delete the selected object |
diff --git a/tui/explorer.go b/tui/explorer.go
index e6287da..c8a9fc2 100644
--- a/tui/explorer.go
+++ b/tui/explorer.go
@@ -95,6 +95,8 @@ func initExplorerPage() {
return attrsPanelKeyHandler(event, currentNode, &explorerCache, explorerAttrsPanel)
})
+ explorerAttrsPanel.SetSelectionChangedFunc(storeAnchoredAttribute(explorerAttrsPanel))
+
treePanel.SetInputCapture(treePanelKeyHandler)
treePanel.SetChangedFunc(treePanelChangeHandler)
@@ -523,6 +525,7 @@ func treePanelChangeHandler(node *tview.TreeNode) {
go app.QueueUpdateDraw(func() {
// TODO: Implement cancellation
reloadExplorerAttrsPanel(node, CacheEntries)
+ selectAnchoredAttribute(explorerAttrsPanel)
})
}
diff --git a/tui/search.go b/tui/search.go
index 14485c3..60c63b8 100644
--- a/tui/search.go
+++ b/tui/search.go
@@ -63,6 +63,7 @@ func initSearchPage() {
searchTreePanel.SetChangedFunc(func(node *tview.TreeNode) {
searchAttrsPanel.Clear()
reloadSearchAttrsPanel(node, true)
+ selectAnchoredAttribute(searchAttrsPanel)
})
searchAttrsPanel = tview.NewTable().
@@ -76,6 +77,7 @@ func initSearchPage() {
return attrsPanelKeyHandler(event, currentNode, &searchCache, searchAttrsPanel)
})
+ searchAttrsPanel.SetSelectionChangedFunc(storeAnchoredAttribute(searchAttrsPanel))
searchLibraryPanel = tview.NewTreeView()
diff --git a/tui/tree.go b/tui/tree.go
index 5ddc48e..595b92a 100644
--- a/tui/tree.go
+++ b/tui/tree.go
@@ -15,6 +15,43 @@ import (
"github.com/rivo/tview"
)
+var selectedAttrName string = "objectClass"
+
+func storeAnchoredAttribute(attrsPanel *tview.Table) func(row, column int) {
+ return func(row, column int) {
+ selectedText := attrsPanel.GetCell(row, 0)
+ cellRef := selectedText.GetReference()
+ if cellRef != nil {
+ attrName, ok := cellRef.(string)
+ if ok {
+ selectedAttrName = attrName
+ }
+ }
+ }
+}
+
+func selectAnchoredAttribute(attrsPanel *tview.Table) {
+ rowCount := attrsPanel.GetRowCount()
+
+ for idx := 0; idx < rowCount; idx++ {
+ cell := attrsPanel.GetCell(idx, 0)
+ cellRef := cell.GetReference()
+ if cellRef == nil {
+ continue
+ }
+
+ cellAttrName, ok := cellRef.(string)
+ if !ok {
+ continue
+ }
+
+ if cellAttrName == selectedAttrName {
+ attrsPanel.Select(idx, 0)
+ break
+ }
+ }
+}
+
func createTreeNodeFromEntry(entry *ldap.Entry) *tview.TreeNode {
_, ok := explorerCache.Get(entry.DN)
@@ -371,7 +408,7 @@ func reloadAttributesPanel(node *tview.TreeNode, attrsTable *tview.Table, useCac
var cellValues []string
- attrsTable.SetCell(row, 0, tview.NewTableCell(cellName))
+ attrsTable.SetCell(row, 0, tview.NewTableCell(cellName).SetReference(cellName))
if FormatAttrs {
cellValues = ldaputils.FormatLDAPAttribute(attribute, TimeFormat)
@@ -380,7 +417,7 @@ func reloadAttributesPanel(node *tview.TreeNode, attrsTable *tview.Table, useCac
}
if !ExpandAttrs {
- myCell := tview.NewTableCell(strings.Join(cellValues, "; "))
+ myCell := tview.NewTableCell(strings.Join(cellValues, "; ")).SetReference(cellName)
if Colors {
color, ok := ldaputils.GetAttrCellColor(cellName, attribute.Values[0])
@@ -395,7 +432,7 @@ func reloadAttributesPanel(node *tview.TreeNode, attrsTable *tview.Table, useCac
}
for idx, cellValue := range cellValues {
- myCell := tview.NewTableCell(cellValue)
+ myCell := tview.NewTableCell(cellValue).SetReference(cellName)
if Colors {
var refValue string
@@ -417,10 +454,11 @@ func reloadAttributesPanel(node *tview.TreeNode, attrsTable *tview.Table, useCac
} else {
if ExpandAttrs {
if AttrLimit == -1 || idx < AttrLimit {
- attrsTable.SetCell(row, 0, tview.NewTableCell(""))
+ attrsTable.SetCell(row, 0, tview.NewTableCell("").SetReference(cellName))
attrsTable.SetCell(row, 1, myCell)
if idx == AttrLimit-1 {
- attrsTable.SetCell(row+1, 1, tview.NewTableCell("[entries hidden]"))
+ attrsTable.SetCell(row+1, 0, tview.NewTableCell("").SetReference(cellName))
+ attrsTable.SetCell(row+1, 1, tview.NewTableCell("[entries hidden]").SetReference(cellName))
row = row + 2
break
}