我可以看到多个值是ldap查询的输出。
我需要从输出中分别过滤OU详细信息。任何以Python方式将其单独删除的方式。非常感谢帮助。
{'raw_dn': b'OU=Security Groups,DC=xxx,DC=com', 'dn': 'OU=Security Groups,DC=xxx,DC=com', 'raw_attributes': {}, 'attributes': {}, 'type': 'searchResEntry'} {'raw_dn': b'OU=FMS,DC=xxx,DC=com', 'dn': 'OU=FMS,DC=xxx,DC=com', 'raw_attributes': {}, 'attributes': {}, 'type': 'searchResEntry
from ldap3 import Server, Connection, SUBTREE, ALL
import json
total_entries = 0
s = Server('XXX', port=389,use_ssl= False,get_info=ALL)
admin_username = "XXX"
admin_password = "xxx"
c = Connection(s, user=admin_username, password=admin_password)
#s = Server(host='servername', port=389, use_ssl=False, get_info='ALL')
#c = Connection(s, auto_bind='NONE', version=3, authentication='ANONYMOUS', client_strategy='SYNC', auto_referrals=True, \
#check_names=True, read_only=False, lazy=False, raise_exceptions=False)
c.bind()
print(c)
#c.start_tls()
c.search(search_base = 'dc=xxx,dc=com',
search_filter = '(objectClass=OrganizationalUnit)',
search_scope = SUBTREE,
paged_size = 500)
total_entries += len(c.response)
a=c.response
print(a)
print(type(a))
for i in a:
print(i)