我尝试使用Net :: LDAPs与Net :: LDAP :: CONTROL :: PAGED通过privlidged绑定返回许多记录,但到目前为止,我失败了,悲惨。我过去曾广泛使用过这个Net :: LDAPs,但我从来没有找到任何证明它与Net :: LDAP兼容的文档:Control :: Paged。我发现的一切都与Net :: LDAP有关。
我得到的错误信息是:未定义的子程序& main :: process_entry,调用于/usr/local/share/perl/5.20.2/Net/LDAP/Search.pm第55行,第755行
这是我的代码:
sub Ldap636{
my ($filter) = $_[0];
my $USERNAME = 'username';
my $PASSWORD = 'password';
my $LDAP_SERVER = 'directory.domain.edu';
my $LDAP_SSL_PORT = '636';
my $LDAP_BASE = 'ou=people,dc=domain,dc=edu';
my $userDN = "uid=$USERNAME,ou=identities,ou=special,dc=domain,dc=edu";
my $ldap = Net::LDAPS->new($LDAP_SERVER, port => $LDAP_SSL_PORT) or die "Could not create LDAP object because:\n$!";
my $ldapMsg = $ldap->bind($userDN, password => $PASSWORD);
die $ldapMsg->error if $ldapMsg->is_error;
my $page = Net::LDAP::Control::Paged->new( size => 100 );
@args = (base => "$LDAP_BASE",
callback => \&process_entry,
filter => $filter,
control => [ $page ],
);
my $cookie;
while (1) {
my $result = $ldap->search(@args);
"LDAP error: server says ",$result->error,"\n" if $result->code;
foreach my $entry ($result->entries ) {
my $cn = $entry->get_value('cn');
my $desc = $entry->get_value('description');
print "$cn - $desc\n";
}
# Get cookie from paged control
my($resp) = $result->control( LDAP_CONTROL_PAGED ) or last;
$cookie = $resp->cookie or last;
$page->cookie($cookie);
}
$ldap->unbind;
}
答案 0 :(得分:1)
我得到的错误信息是:Undefined subroutine& main :: process_entry 在/usr/local/share/perl/5.20.2/Net/LDAP/Search.pm第55行调用, 第755行
您已将process_entry
写为回调,但您没有编写该子例程。这就是你得到上述错误的原因。