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

Function warnAttrsList

tui/tree.go:60–145  ·  view source on GitHub ↗

warnAttrsList shows a confirmation modal if the given attrs list is non-empty and is missing attributes required by the godap interface for the current LDAP flavor. onProceed is called when the user confirms or no warning is needed.

(attrsList string, currentFocus tview.Primitive, onProceed func())

Source from the content-addressed store, hash-verified

58// and is missing attributes required by the godap interface for the current
59// LDAP flavor. onProceed is called when the user confirms or no warning is needed.
60func warnAttrsList(attrsList string, currentFocus tview.Primitive, onProceed func()) {
61 attrs := parseAttrsList(attrsList)
62 if len(attrs) == 0 {
63 onProceed()
64 return
65 }
66
67 // Build a normalized set and check for wildcard in one pass.
68 set := make(map[string]bool, len(attrs))
69 for _, a := range attrs {
70 n := strings.ToLower(strings.TrimSpace(a))
71 if n == "*" {
72 onProceed()
73 return
74 }
75 set[n] = true
76 }
77
78 var missing []string
79
80 switch lc.Flavor {
81 case ldaputils.MicrosoftADFlavor:
82 if !set["name"] && !set["1.2.840.113556.1.4.1"] {
83 missing = append(missing, "name")
84 }
85 if !set["objectclass"] && !set["2.5.4.0"] {
86 missing = append(missing, "objectClass")
87 }
88 if !set["useraccountcontrol"] {
89 missing = append(missing, "userAccountControl")
90 }
91 if !set["isdeleted"] {
92 missing = append(missing, "isDeleted")
93 }
94 if !set["isrecycled"] {
95 missing = append(missing, "isRecycled")
96 }
97 case ldaputils.BasicLDAPFlavor:
98 if !set["objectclass"] && !set["2.5.4.0"] {
99 missing = append(missing, "objectClass")
100 }
101 if !set["cn"] {
102 missing = append(missing, "cn")
103 }
104 if !set["ou"] {
105 missing = append(missing, "ou")
106 }
107 if !set["dc"] {
108 missing = append(missing, "dc")
109 }
110 if !set["name"] {
111 missing = append(missing, "name")
112 }
113 if !set["uid"] {
114 missing = append(missing, "uid")
115 }
116 }
117

Callers 2

openSearchBaseDNFormFunction · 0.85
openExplorerSettingsFormFunction · 0.85

Calls 1

parseAttrsListFunction · 0.85

Tested by

no test coverage detected