'one', filt-6ren">
gpt4 book ai didi

perl - 从 1000 增加限制?

转载 作者:行者123 更新时间:2023-12-01 05:39:35 26 4
gpt4 key购买 nike

当我这样搜索时

my $mesg = $ldap->search(
base => "OU=test,DC=example,DC=com",
scope => 'one',
filter => '(objectClass=organizationalPerson)',
attrs => ['distinguishedName', 'displayName', 'sAMAccountName', 'employeeID'],
);

我只得到 1000 个条目,我预计会有 ~20000 个条目。

是否可以在我的 Perl 脚本中增加此限制,还是必须在服务器上进行更改?

最佳答案

解决方案是像这样使用分页搜索

use Net::LDAP;
use Net::LDAP::Control::Paged;
use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED );

my $page = Net::LDAP::Control::Paged->new(size => 999);
my $cookie;

while (1) {
$mesg = $ldap->search(
base => "OU=test,DC=example,DC=com",
scope => 'one',
filter => '(objectClass=organizationalPerson)',
attrs => ['distinguishedName', 'displayName', 'sAMAccountName', 'employeeID'],
control => [$page]
);

$mesg->code && die "Error on search: $@ : " . $mesg->error;
while (my $adentry = $mesg->pop_entry()) {

# process $adentry
}

my ($resp) = $mesg->control(LDAP_CONTROL_PAGED) or last;
$cookie = $resp->cookie or last;
# Paging Control
$page->cookie($cookie);
}

if ($cookie) {
print "abnormal exit\n";
# Abnormal exit, so let the server know we do not want any more
$page->cookie($cookie);
$page->size(0);
$ldap->search(control => [$page]);
}

关于perl - 从 1000 增加限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5830860/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com