I'm trying to list users of a specific group, as below:
import pyad.adquery
from pyad import adgroup,aduser
q = pyad.adquery.ADQuery()
q.execute_query(
attributes=["SamAccountName"],
where_clause="objectClass = 'group'",
base_dn="CN=GROUP2,OU=Toto,OU=Titi,OU=Tutu,DC=dc,DC=rootdc,DC=com"
)
for row in q.get_results():
group = adgroup.ADGroup.from_cn(row["SamAccountName"])
members = group.get_members()
for member in members:
print(member.get_attribute("samAccountName"))
This returns a pywintypes.com_error: There is no such object on the server (the exact error is in French and I'm trying to translate as Active Directorying as possible).
However when changing CN=GROUP2 by CN=GROUP1 it works and lists all users of GROUP1.
Both GROUP1 and GROUP2 exists in the exact same OU, have the same properties, and can be queried using RSAT Powershell applets.
Any clue ? I feel like I'm facing some sort of race condition I'm not able to troubleshoot.
I'm trying to list users of a specific group, as below:
This returns a
pywintypes.com_error: There is no such object on the server
(the exact error is in French and I'm trying to translate as Active Directorying as possible).However when changing
CN=GROUP2
byCN=GROUP1
it works and lists all users of GROUP1. Both GROUP1 and GROUP2 exists in the exact same OU, have the same properties, and can be queried using RSAT Powershell applets. Any clue ? I feel like I'm facing some sort of race condition I'm not able to troubleshoot.Thanks a lot