Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python LDAP3模块获得1000多个结果或备选方案_Python_Python 3.x_Active Directory_Ldap3 - Fatal编程技术网

Python LDAP3模块获得1000多个结果或备选方案

Python LDAP3模块获得1000多个结果或备选方案,python,python-3.x,active-directory,ldap3,Python,Python 3.x,Active Directory,Ldap3,我正在尝试连接到特定端口上的服务器,并进行匿名SSL身份验证。我编写了上面的脚本来获取“AppID=*”的结果。我只能打印1000条记录,之后我遇到以下错误: 回溯(最近一次调用last):文件“C:/Fetch data.py”,第43行, 在里面 对于结果中的条目:文件“C:\Users\xyz\AppData\Local\Programs\Python36\lib\site packages\ldap3\extend\standard\PagedSearch.py”, 第75行,在分页搜索

我正在尝试连接到特定端口上的服务器,并进行匿名SSL身份验证。我编写了上面的脚本来获取“AppID=*”的结果。我只能打印1000条记录,之后我遇到以下错误:

回溯(最近一次调用last):文件“C:/Fetch data.py”,第43行, 在里面 对于结果中的条目:文件“C:\Users\xyz\AppData\Local\Programs\Python36\lib\site packages\ldap3\extend\standard\PagedSearch.py”, 第75行,在分页搜索生成器中 raise LDAPOperationResult(结果=结果['result'],描述=结果['description'],dn=结果['dn'], 消息=结果['message'],响应类型=结果['type']) ldap3.core.exceptions.LDAPSizeLimitExceededResult: LDAPSizeLimiteExceededResult-4-SizeLimiteExceed-None-None- searchResDone-无

我已经尝试了提供的解决方案


我试着看了一下文件,但没有成功。有没有办法读取完整的输出。(我想有超过5k条记录)

这里的问题是,您的代码将生成一个生成器对象

# import class and constants
from ldap3 import Server, Connection, ALL, SUBTREE

# define the server
s = Server(host='xyz', port=xxxx, use_ssl=True, 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()
results = c.extend.standard.paged_search(
    search_base = 'Ou=XYZ,dc=org,dc=com',
    search_filter = '(AppID=*)',
    search_scope = SUBTREE,
    get_operational_attributes=True,
    attributes=['*'],
    generator=True,
    paged_size=None
)
i=0

for entries in results:
    print(entries)
    i+=1
print(i)
这将为您提供所需的所有详细信息。
参考资料。

我试过类似的方法,效果很好。你已经回答了我的问题。谢谢D
from ldap3 import Server, Connection, SUBTREE
import ldap3
total_entries = 0
# define the server
s = Server(host='xyz', port=xxxx, use_ssl=True, get_info=ldap3.NONE)
c = Connection(s,authentication='ANONYMOUS') 
# subtitute your filter here 
filter = '(&(objectClass=group)(sAMAccountName=))'
entry_generator = c.extend.standard.paged_search(search_base = 'Ou=XYZ,dc=org,dc=com',
                                                 search_filter = filter,
                                                 search_scope = SUBTREE,
                                                 get_operational_attributes=True,
                                                 attributes = ['*'],
                                                 paged_size = 1000,
                                                 generator=True)
for entry in entry_generator:
    total_entries += 1
    print(entry['dn'], entry['attributes'])
print('Total entries retrieved:', total_entries)