Skip to content

Commit fc08e29

Browse files
committed
Fixed a regression from v2.10.9 regarding coloring of the userAccountControl.
1 parent 9f7b920 commit fc08e29

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

tui/theme.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,12 @@ func GetEntryColor(entry *ldap.Entry) (tcell.Color, bool) {
233233
return baseTheme.PrimaryTextColor, false
234234
}
235235

236-
func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
236+
func GetAttrCellColor(cellName string, cellValue ldaputils.FormattedAttrValue) (string, bool) {
237237
var color string = ""
238238

239239
switch cellName {
240240
case "lastLogonTimestamp", "accountExpires", "badPasswordTime", "lastLogoff", "lastLogon", "pwdLastSet", "creationTime", "lockoutTime":
241-
intValue, err := strconv.ParseInt(cellValue, 10, 64)
241+
intValue, err := strconv.ParseInt(cellValue.OriginalValue, 10, 64)
242242
if err == nil {
243243
unixTime := (intValue - 116444736000000000) / 10000000
244244
t := time.Unix(unixTime, 0).UTC()
@@ -257,7 +257,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
257257
color = "gray"
258258
case "whenCreated", "whenChanged":
259259
layout := "20060102150405.0Z"
260-
t, err := time.Parse(layout, cellValue)
260+
t, err := time.Parse(layout, cellValue.OriginalValue)
261261
if err == nil {
262262
daysDiff := int(time.Since(t).Hours() / 24)
263263

@@ -270,7 +270,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
270270
}
271271
}
272272
case "lockoutDuration", "msDS-LockoutDuration", "lockOutObservationWindow", "msDS-LockoutObservationWindow":
273-
duration, err := ldaputils.ParseMSDuration(cellValue)
273+
duration, err := ldaputils.ParseMSDuration(cellValue.OriginalValue)
274274
if err == nil {
275275
if duration <= 5*60*time.Second {
276276
color = "green"
@@ -281,7 +281,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
281281
}
282282
}
283283
case "maxPwdAge", "msDS-MaximumPasswordAge":
284-
duration, err := ldaputils.ParseMSDuration(cellValue)
284+
duration, err := ldaputils.ParseMSDuration(cellValue.OriginalValue)
285285
if err == nil {
286286
if duration <= 30*24*time.Hour {
287287
color = "red"
@@ -292,7 +292,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
292292
}
293293
}
294294
case "minPwdAge", "msDS-MinimumPasswordAge":
295-
duration, err := ldaputils.ParseMSDuration(cellValue)
295+
duration, err := ldaputils.ParseMSDuration(cellValue.OriginalValue)
296296
if err == nil {
297297
if duration == 0*time.Second {
298298
color = "green"
@@ -303,7 +303,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
303303
}
304304
}
305305
case "forceLogoff":
306-
duration, err := ldaputils.ParseMSDuration(cellValue)
306+
duration, err := ldaputils.ParseMSDuration(cellValue.OriginalValue)
307307
if err == nil {
308308
if duration == 0*time.Second {
309309
color = "red"
@@ -314,7 +314,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
314314
}
315315
}
316316
case "msDS-UserTGTLifetime", "msDS-ComputerTGTLifetime", "msDS-ServiceTGTLifetime":
317-
duration, err := ldaputils.ParseMSDuration(cellValue)
317+
duration, err := ldaputils.ParseMSDuration(cellValue.OriginalValue)
318318
if err == nil {
319319
if duration >= 24*time.Hour {
320320
color = "green"
@@ -325,7 +325,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
325325
}
326326
}
327327
case "lockoutThreshold", "msDS-LockoutThreshold":
328-
intValue, err := strconv.ParseInt(cellValue, 10, 64)
328+
intValue, err := strconv.ParseInt(cellValue.OriginalValue, 10, 64)
329329
if err == nil {
330330
if intValue == 0 {
331331
color = "green"
@@ -336,7 +336,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
336336
}
337337
}
338338
case "minPwdLength", "msDS-MinimumPasswordLength":
339-
intValue, err := strconv.ParseInt(cellValue, 10, 64)
339+
intValue, err := strconv.ParseInt(cellValue.OriginalValue, 10, 64)
340340
if err == nil {
341341
if intValue >= 12 {
342342
color = "red"
@@ -347,7 +347,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
347347
}
348348
}
349349
case "badPwdCount":
350-
intValue, err := strconv.ParseInt(cellValue, 10, 64)
350+
intValue, err := strconv.ParseInt(cellValue.OriginalValue, 10, 64)
351351
if err == nil {
352352
if intValue > 0 {
353353
color = "yellow"
@@ -356,7 +356,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
356356
}
357357
}
358358
case "logonCount":
359-
intValue, err := strconv.ParseInt(cellValue, 10, 64)
359+
intValue, err := strconv.ParseInt(cellValue.OriginalValue, 10, 64)
360360
if err == nil {
361361
if intValue >= 10 {
362362
color = "green"
@@ -368,7 +368,7 @@ func GetAttrCellColor(cellName string, cellValue string) (string, bool) {
368368
}
369369
}
370370

371-
switch cellValue {
371+
switch cellValue.FormattedValue {
372372
case "TRUE", "Enabled", "Normal", "PwdNotExpired":
373373
color = "green"
374374
case "FALSE", "NotNormal", "PwdExpired":

tui/tree.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ func handleAttrsKeyEnter(currentNode *tview.TreeNode, attrsPanel *tview.Table, c
439439
myCell := tview.NewTableCell(cellValue.FormattedValue).SetReference(cellValue.OriginalValue)
440440

441441
if Colors {
442-
color, ok := GetAttrCellColor(attrName, cellValue.OriginalValue)
442+
color, ok := GetAttrCellColor(attrName, cellValue)
443443
if ok {
444444
myCell.SetTextColor(tcell.GetColor(color))
445445
}
@@ -591,8 +591,8 @@ func reloadAttributesPanel(node *tview.TreeNode, attrsTable *tview.Table, useCac
591591
myCell = tview.NewTableCell(fmtAttrs.ValuesStr())
592592
myCell.SetReference(nil)
593593

594-
if Colors {
595-
color, ok := GetAttrCellColor(cellName, fmtAttrs.Values[0].OriginalValue)
594+
if Colors && len(fmtAttrs.Values) == 1 {
595+
color, ok := GetAttrCellColor(cellName, fmtAttrs.Values[0])
596596
if ok {
597597
myCell.SetTextColor(tcell.GetColor(color))
598598
}
@@ -610,7 +610,7 @@ func reloadAttributesPanel(node *tview.TreeNode, attrsTable *tview.Table, useCac
610610
myCell = tview.NewTableCell(cellValue.FormattedValue).SetReference(cellValue.OriginalValue)
611611

612612
if Colors {
613-
color, ok := GetAttrCellColor(cellName, cellValue.OriginalValue)
613+
color, ok := GetAttrCellColor(cellName, cellValue)
614614

615615
if ok {
616616
myCell.SetTextColor(tcell.GetColor(color))

0 commit comments

Comments
 (0)