What I should I do to get users uid
number, mail, employeenumber
?
from ldap3 import Server, Connection
# clear connection
my_server = 'XXX'
my_user = 'uid=idmsa,ou=People,ou=auth,o=csun'
my_password = 'password'
s0 = Server(my_server)
c0 = Connection(s0, my_user, my_password)
c0.bind()
c0.search("o=csun", "(cn=*)")
print(c0.entries)
OUTPUT
DN: uid=aa22342,ou=People,ou=Auth,o=CSUN - STATUS: Read - READ TIME: 2021-06-24T10:27:10.169992
You can pass in the list of attributes to be returned :
c0.search("o=csun", "(cn=*)", attributes=['uid', 'uidNumber', 'mail'])
And then you can iterate over the results with :
for entry in c0.response:
print(entry['dn'])
print(entry['attributes'])
# ...