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

Function openUpdateUacForm

tui/explorer.go:164–235  ·  view source on GitHub ↗
(node *tview.TreeNode, cache *EntryCache, done func())

Source from the content-addressed store, hash-verified

162}
163
164func openUpdateUacForm(node *tview.TreeNode, cache *EntryCache, done func()) {
165 currentFocus := app.GetFocus()
166 baseDN := node.GetReference().(string)
167
168 updateUacForm := NewXForm()
169 //assignFormTheme(updateUacForm)
170 updateUacForm.SetInputCapture(handleEscape(treePanel))
171 updateUacForm.SetItemPadding(0)
172
173 var checkboxState int = 0
174 obj, _ := cache.Get(baseDN)
175 if obj != nil {
176 uacValue, err := strconv.Atoi(obj.GetAttributeValue("userAccountControl"))
177 if err == nil {
178 checkboxState = uacValue
179 } else {
180 return
181 }
182 }
183
184 updateUacForm.
185 AddTextView("Raw UAC Value", strconv.Itoa(checkboxState), 0, 1, false, true)
186
187 uacValues := make([]int, 0)
188 for key := range ldaputils.UacFlags {
189 uacValues = append(uacValues, key)
190 }
191 sort.Ints(uacValues)
192
193 for _, val := range uacValues {
194 uacValue := val
195 updateUacForm.AddCheckbox(
196 ldaputils.UacFlags[uacValue].Present,
197 checkboxState&uacValue != 0,
198 func(checked bool) {
199 if checked {
200 checkboxState |= uacValue
201 } else {
202 checkboxState &^= uacValue
203 }
204
205 uacPreview := updateUacForm.GetFormItemByLabel("Raw UAC Value").(*tview.TextView)
206 if uacPreview != nil {
207 uacPreview.SetText(strconv.Itoa(checkboxState))
208 }
209 })
210 }
211
212 updateUacForm.
213 AddButton("Go Back", func() {
214 app.SetRoot(appPanel, true).SetFocus(currentFocus)
215 }).
216 AddButton("Update", func() {
217 strCheckboxState := strconv.Itoa(checkboxState)
218 err := lc.ModifyAttribute(baseDN, "userAccountControl", []string{strCheckboxState})
219
220 if err != nil {
221 handleLDAPError(err)

Callers 2

initSearchPageFunction · 0.85
treePanelKeyHandlerFunction · 0.85

Calls 8

AddTextViewMethod · 0.95
AddCheckboxMethod · 0.95
NewXFormFunction · 0.85
handleEscapeFunction · 0.85
handleLDAPErrorFunction · 0.85
updateLogFunction · 0.85
GetMethod · 0.80
ModifyAttributeMethod · 0.80

Tested by

no test coverage detected