Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions pyLAPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,21 @@ def get(self, sAMAccountName='*'):
attributes=['objectSid']
))
dn, sid = None, None
try:
dn = responses[0].entry_dn
sid = format_sid(responses[0]['objectSid'].raw_values[0])
except IndexError:
for entry in responses:
# paged_search() yields raw response dicts, not Entry objects,
# and can also yield searchResRef referrals.
if entry['type'] != 'searchResEntry':
continue
dn = entry['dn']
raw_sid = entry['raw_attributes'].get('objectSid', [])
if len(raw_sid) != 0:
sid = format_sid(raw_sid[0])
break

if dn is None:
print("[!] Computer not found in LDAP: %s" % sAMAccountName)

if dn is None and sid is None:
print("[!] Target computer does not exist! (wrong domain?)")
return []
else:
print("[+] Target computer found: %s" % dn)

Expand Down
Loading