Here is my script which I wrote for ldap3 and it is working but I want to print the results in a CSV file. What am I doing wrong?
from ldap3 import Server, Connection, ALL
import csv
server = Server('XYZ', get_info=ALL)
conn = Connection(server, 'uid=idmsa,ou=People,ou=auth,o=csun', 'XYZ', auto_bind=True)
#Fetches the given attributes
conn.search('o=csun', '(&(objectclass=person)(uid>=2147483648))', attributes=['uid', 'employeenumber','csunPrimaryAffiliation'])
header = ['uid', 'employeenumber','csunPrimaryAffiliation']
data = ['', '', '']
with open('file.csv', 'w', encoding='UTF8') as f:
writer = csv.writer(f)
writer.writerow(header)
writer.writerow(data)
conn.entries