ruff: apply ruff
parent
762a9ac102
commit
3a1e93a386
|
@ -758,9 +758,11 @@ class ldap(connection):
|
||||||
Retrieves user information from the LDAP server.
|
Retrieves user information from the LDAP server.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
----
|
||||||
input_attributes (list): Optional. List of attributes to retrieve for each user.
|
input_attributes (list): Optional. List of attributes to retrieve for each user.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
-------
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
if len(self.args.users) > 1:
|
if len(self.args.users) > 1:
|
||||||
|
@ -789,16 +791,16 @@ class ldap(connection):
|
||||||
users = parse_result_attributes(resp)
|
users = parse_result_attributes(resp)
|
||||||
# we print the total records after we parse the results since often SearchResultReferences are returned
|
# we print the total records after we parse the results since often SearchResultReferences are returned
|
||||||
self.logger.display(f"Total records returned: {len(users):d}")
|
self.logger.display(f"Total records returned: {len(users):d}")
|
||||||
self.logger.highlight(f"{'Username':<30} {'Last PW Set':<20}\t{'Description':<60} " + ' '.join(f"{a}" for a in self.args.ldap_attributes) if self.args.ldap_attributes else '')
|
self.logger.highlight(f"{'Username':<30} {'Last PW Set':<20}\t{'Description':<60} " + " ".join(f"{a}" for a in self.args.ldap_attributes) if self.args.ldap_attributes else "")
|
||||||
for user in users:
|
for user in users:
|
||||||
self.logger.debug(f"{user=}")
|
self.logger.debug(f"{user=}")
|
||||||
# we default attributes to blank strings if they don't exist in the dict
|
# we default attributes to blank strings if they don't exist in the dict
|
||||||
timestamp_seconds = int(user.get('pwdLastSet', '')) / 10**7
|
timestamp_seconds = int(user.get("pwdLastSet", "")) / 10**7
|
||||||
start_date = datetime(1601, 1, 1)
|
start_date = datetime(1601, 1, 1)
|
||||||
parsed_pw_last_set = (start_date + timedelta(seconds=timestamp_seconds)).replace(microsecond=0).strftime("%Y-%m-%d %H:%M:%S")
|
parsed_pw_last_set = (start_date + timedelta(seconds=timestamp_seconds)).replace(microsecond=0).strftime("%Y-%m-%d %H:%M:%S")
|
||||||
if parsed_pw_last_set == "1601-01-01 00:00:00":
|
if parsed_pw_last_set == "1601-01-01 00:00:00":
|
||||||
parsed_pw_last_set = "<never>"
|
parsed_pw_last_set = "<never>"
|
||||||
self.logger.highlight(f"{user.get('sAMAccountName', ''):<30} {parsed_pw_last_set:<20}\t{user.get('description', ''):<60} " + ' '.join(f"{user.get(a, '')}" for a in self.args.ldap_attributes) if self.args.ldap_attributes else '')
|
self.logger.highlight(f"{user.get('sAMAccountName', ''):<30} {parsed_pw_last_set:<20}\t{user.get('description', ''):<60} " + " ".join(f"{user.get(a, '')}" for a in self.args.ldap_attributes) if self.args.ldap_attributes else "")
|
||||||
def groups(self):
|
def groups(self):
|
||||||
# Building the search filter
|
# Building the search filter
|
||||||
search_filter = "(objectCategory=group)"
|
search_filter = "(objectCategory=group)"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from argparse import _StoreTrueAction, Action
|
from argparse import _StoreTrueAction
|
||||||
|
|
||||||
|
|
||||||
def proto_args(parser, std_parser, module_parser):
|
def proto_args(parser, std_parser, module_parser):
|
||||||
|
|
Loading…
Reference in New Issue