我正在尝试通过 LDAP 查询 Active Directory 以列出组,但我得到的信息超出了我的需要。如何解析结果以仅获取所有组名。例如:LOCAL_java_read
和其他人而不是来自结果的其余人。
from ldap3 import Server, Connection, ALL
server = Server('xxx', port=389, get_info=ALL)
conn = Connection(server, 'username', 'password', auto_bind=True, raise_exceptions=True)
conn.search('OU=Groups,OU=CH,DC=google,DC=com', '(objectclass=group)')
groups=conn.entries
print (groups)
结果:
[DN: CN=LOCAL_java_read,OU=Groups,OU=CH,DC=google,DC=com - STATUS: Read - READ TIME: 2019-03-27T14:22:08.072330
, DN: CN=LOCAL_python_read,OU=Groups,OU=CH,DC=google,DC=com - STATUS: Read - READ TIME: 2019-03-27T14:22:08.072330
, DN: CN=LOCAL_php_read,OU=Groups,OU=CH,DC=google,DC=com - STATUS: Read - READ TIME: 2019-03-27T14:22:08.072330]