ruff: apply ruff

main
Marshall Hallenbeck 2024-03-21 11:01:46 -04:00 committed by Marshall Hallenbeck
parent 762a9ac102
commit 3a1e93a386
2 changed files with 6 additions and 4 deletions

View File

@ -758,9 +758,11 @@ class ldap(connection):
Retrieves user information from the LDAP server.
Args:
----
input_attributes (list): Optional. List of attributes to retrieve for each user.
Returns:
-------
None
"""
if len(self.args.users) > 1:
@ -789,16 +791,16 @@ class ldap(connection):
users = parse_result_attributes(resp)
# 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.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:
self.logger.debug(f"{user=}")
# 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)
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":
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):
# Building the search filter
search_filter = "(objectCategory=group)"

View File

@ -1,4 +1,4 @@
from argparse import _StoreTrueAction, Action
from argparse import _StoreTrueAction
def proto_args(parser, std_parser, module_parser):