MCPcopy Create free account
hub / github.com/XiaoliChan/LDAPShell / do_clear_rbcd

Method do_clear_rbcd

utils/ldap_shell.py:325–347  ·  view source on GitHub ↗
(self, computer_name)

Source from the content-addressed store, hash-verified

323 raise Exception('The server returned an error: %s', self.client.result['message'])
324
325 def do_clear_rbcd(self, computer_name):
326
327 success = self.client.search(self.domain_dumper.root, '(sAMAccountName=%s)' % escape_filter_chars(computer_name), attributes=['objectSid', 'msDS-AllowedToActOnBehalfOfOtherIdentity'])
328 if success is False or len(self.client.entries) != 1:
329 raise Exception("Error expected only one search result got %d results", len(self.client.entries))
330
331 target = self.client.entries[0]
332 target_sid = target["objectsid"].value
333 print("Found Target DN: %s" % target.entry_dn)
334 print("Target SID: %s\n" % target_sid)
335
336 sd = self.create_empty_sd()
337
338 self.client.modify(target.entry_dn, {'msDS-AllowedToActOnBehalfOfOtherIdentity':[ldap3.MODIFY_REPLACE, [sd.getData()]]})
339 if self.client.result['result'] == 0:
340 print('Delegation rights cleared successfully!')
341 else:
342 if self.client.result['result'] == 50:
343 raise Exception('Could not modify object, the server reports insufficient rights: %s', self.client.result['message'])
344 elif self.client.result['result'] == 19:
345 raise Exception('Could not modify object, the server reports a constrained violation: %s', self.client.result['message'])
346 else:
347 raise Exception('The server returned an error: %s', self.client.result['message'])
348
349 def do_dump(self, line):
350 print('Dumping domain info...')

Callers

nothing calls this directly

Calls 2

create_empty_sdMethod · 0.95
searchMethod · 0.80

Tested by

no test coverage detected