Using ActiveDirectory and ldap3 from Python, I am trying to retrieve a list of group members. Realizing that this is a common question, I tried many of the solutions posted here and on Google.
Here's my situation:
Directory setup:
Using ldap3, this code correctly return a list of users:
server = Server('ricktestad2.mydomain.org')
conn = Connection(server, 'Admin', 'xxxxxx', client_strategy=SAFE_SYNC, auto_bind=True)
obj_person = ObjectDef(['person', 'organizationalPerson', 'user'] , conn)
r = Reader(conn, obj_person, 'OU=Users,OU=ricktestad2,DC=ricktestad2,DC=mydomain,DC=org')
r.search()
Using this code to retrieve the members of group 'rds.eval.mda.admin' returns 0 entries:
cn2='OU=Users,OU=ricktestad2,DC=ricktestad2,DC=mydomain,DC=org'
conn2 = Connection(server, 'Admin', 'xxxxxx', client_strategy=SAFE_SYNC, auto_bind=True)
conn2.search(
search_base=cn2,
search_filter='(&(objectCategory=group)(CN=rds.eval.mda.admin))',
search_scope='SUBTREE',
attributes = ['member'])
I've tried countless permutations of the cn and filter with no success.
Any suggestions?