Skip to content

Commit 6e59002

Browse files
authored
Edit_ldarp_parser
1 parent 5b14c3f commit 6e59002

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

nxc/parsers/ldap_results.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ def parse_result_attributes(ldap_response):
88
continue
99
attribute_map = {}
1010
for attribute in entry["attributes"]:
11-
attribute_map[str(attribute["type"])] = str(attribute["vals"][0])
11+
val_list = []
12+
for val in attribute["vals"].components:
13+
try:
14+
# Attempt to decode as UTF-8
15+
decoded_val = val.decode("utf-8")
16+
except (UnicodeDecodeError, AttributeError):
17+
# If it fails, fall back to hexadecimal representation
18+
decoded_val = val.hex() if isinstance(val, bytes) else str(val)
19+
val_list.append(decoded_val)
20+
attribute_map[str(attribute["type"])] = val_list if len(val_list) > 1 else val_list[0]
1221
parsed_response.append(attribute_map)
13-
return parsed_response
22+
return parsed_response

0 commit comments

Comments
 (0)