Python 3.x 如果计算机已启用,则Python pyad查询不会返回

Python 3.x 如果计算机已启用,则Python pyad查询不会返回,python-3.x,active-directory,pyad,Python 3.x,Active Directory,Pyad,我对python3 pyad模块有问题。 我想用一些信息查询我的active directory环境中的所有PC,以及它们是否已启用 代码如下: q = pyad.adquery.ADQuery() q.execute_query( attributes = ["CN", "OperatingSystem", "OperatingSystemVersion", "Description", "Enabled"], where_clause = "objectClass = 'Co

我对python3 pyad模块有问题。 我想用一些信息查询我的active directory环境中的所有PC,以及它们是否已启用

代码如下:

q = pyad.adquery.ADQuery()
q.execute_query(
    attributes = ["CN", "OperatingSystem", "OperatingSystemVersion", "Description", "Enabled"],
    where_clause = "objectClass = 'Computer'",
    base_dn = "OU=Client,OU=####,OU=########,DC=###############,DC=########,DC=local"
)

ad_result = []
for row in q.get_results():
    ad_result.append(row)
    print(row)
这就是我得到的回报:

{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled':无,'Description':无,'OperatingSystemVersion':'10.0(17763)','OperatingSystem':'Windows10Pro','CN':''
{'Enabled':无,'Description':无,'OperatingSystemVersion':'10.0(17763)','OperatingSystem':'Windows10Pro','CN':''
{'Enabled':无,'Description':无,'OperatingSystemVersion':'10.0(17763)','OperatingSystem':'Windows10Pro','CN':''
{'Enabled':无,'Description':无,'OperatingSystemVersion':'10.0(17763)','OperatingSystem':'Windows10Pro','CN':''
{'Enabled':无,'Description':无,'OperatingSystemVersion':'10.0(17763)','OperatingSystem':'Windows10Pro','CN':''
{'Enabled':无,'Description':无,'OperatingSystemVersion':'10.0(17763)','OperatingSystem':'Windows10Pro','CN':''
{'Enabled':无,'Description':无,'OperatingSystemVersion':'10.0(17763)','OperatingSystem':'Windows10Pro','CN':''
因此,我的问题是,我没有将“启用”状态恢复为TrueFalse,而是只得到None。 当我通过Powershell进行查询时,它工作得很好,但我确实希望使用python。 我不想在我的脚本中添加一些Powershell csv导出。
如果有人知道我希望得到一个答案,谢谢。

我不知道为什么会出现这种行为,但我知道在哪里可以获得“Enabled”属性:

comp = adcomputer.ADComputer.from_cn("xxxxxxxx")
comp.get_user_account_control_settings()
将产生:

{'SCRIPT': False,
 'ACCOUNTDISABLE': False,
...
对于启用的机器和禁用的机器:

{'SCRIPT': False,
 'ACCOUNTDISABLE': True,
...
对于描述字段:

comp.get_allowed_attributes()
如果属性名称在上述调用的输出中,则可以使用以下命令进行查询:

comp.get_attribute('description')