# Specify the file path containing the LDAP search command output ldapsearch_output_file = "ldap_search_output.txt" # Read the LDAP search output from the file with open(ldapsearch_output_file, "r") as file: ldapsearch_output = file.read() # Split the LDAP search output into entries entries = ldapsearch_output.strip().split("\n\n") # Create an HTML string to store the HTML content html_content = "\n\n" # Iterate through each LDAP entry and convert it to HTML for entry in entries: lines = entry.split("\n") html_content += "\n" for line in lines: key, value = line.split(": ", 1) html_content += f"\n" html_content += "
{key}{value}
\n" # Close the HTML document html_content += "\n" # Write the HTML content to a file with open("ldap_search_results.html", "w") as html_file: html_file.write(html_content) print('HTML file "ldap_search_results.html" has been created.')