1

I am trying to get a list of disabled users from active directory. I have working code for pulling AD entries, but I get computers as well as users in the returned results. I also don't know how to filter for disabled accounts if possible.

import ldap3
from ldap3 import Server, Connection, ObjectDef, AttrDef, Reader, Writer, ALL
server = Server(DC, get_info=ALL)
conn = ldap3.Connection(server, user="doamin.name\\" + user, password=password, authentication='NTLM')
conn.bind()
obj_person = ObjectDef(['user'],  conn)
r = Reader(conn, obj_person, 'ou=ou,dc=domain,dc=com')
r.search()

for u in r.entries:
    print(u.entry_to_json(include_empty=False))

conn.unbind()
Antikythera
  • 91
  • 1
  • 8

0 Answers0