Home > Archive > LDAP > November 2005 > Error when using Page Control
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Error when using Page Control
|
|
| Aaron Giuoco 2005-11-02, 7:03 pm |
| Hi all,
I am trying to use the page control on a >1000 record LDAP query. I =
pretty much just copied the code from the examples and modified it for =
my use, but I might have messed something up. The error I get when I =
run the program is:
Can't call method "cookie" without a package or object reference at =
ldap_test.pl line 95, <DATA> line 461.
Here is the code around that line number:
76. while(1) {
77. my $searchRes =3D $ldap->search( @searchArgs );
78. if ($searchRes->code =3D=3D 0) {
79. foreach my $entry ($searchRes->entries) {
# Do stuff with the entry
93. }
94. my $resp =3D $searchRes->control( LDAP_CONTROL_PAGED ) or last;
95. $cookie =3D $resp->cookie or last;
96. $page->cookie($cookie);
97. } else {
98. print LOG "Error with search:\n" . $searchRes->error . "\n";
99. last;
100. }
101. }
My script is processing the information inside the foreach() correctly, =
but it errors out when it hits line 95. Thanks in advance for any help =
you can provide.
___________________________
Aaron Giuoco
Assistant Systems Admin
Atlantia Offshore Limited
e: agiuoco@atlantia.com
ph: 281-899-4385
| |
| Justin B. Alcorn 2005-11-02, 7:03 pm |
| In a process of deep contemplation, Giuoco, Aaron carefully constucted
the following missive on 11/2/2005 12:02 PM:
> Hi all,
>
> I am trying to use the page control on a >1000 record LDAP query. I pretty much just copied the code from the examples and modified it for my use, but I might have messed something up. The error I get when I run the program is:
>
> Can't call method "cookie" without a package or object reference at ldap_test.pl line 95, <DATA> line 461.
>
> Here is the code around that line number:
>
>
> 76. while(1) {
> 77. my $searchRes = $ldap->search( @searchArgs );
> 78. if ($searchRes->code == 0) {
> 79. foreach my $entry ($searchRes->entries) {
> # Do stuff with the entry
> 93. }
> 94. my $resp = $searchRes->control( LDAP_CONTROL_PAGED ) or last;
> 95. $cookie = $resp->cookie or last;
> 96. $page->cookie($cookie);
> 97. } else {
> 98. print LOG "Error with search:\n" . $searchRes->error . "\n";
> 99. last;
> 100. }
> 101. }
>
> My script is processing the information inside the foreach() correctly, but it errors out when it hits line 95. Thanks in advance for any help you can provide.
From Net::LDAP::Message:
control ( OID, ... )
Return a *list* of controls with the given OIDs that were returned
from the server.
So you want:
my ($resp) = $searchRes->control( LDAP_CONTROL_PAGED ) or last;
Then $resp will contain the first (and only) control, which is what you
want. I got bit on the same problem, took more than a 1/2 hour to
realize the problem.
| |
| Aaron Giuoco 2005-11-02, 7:03 pm |
| Shazbot! Yes, that was my problem. It returns a list. Thanks.
AG
> -----Original Message-----
> From: Justin B. Alcorn [mailto:justin@jalcorn.net]
> Sent: Wednesday, November 02, 2005 12:37 PM
> To: Giuoco, Aaron; perl-ldap@perl.org
> Subject: Re: Error when using Page Control
>=20
>=20
> In a process of deep contemplation, Giuoco, Aaron carefully=20
> constucted=20
> the following missive on 11/2/2005 12:02 PM:
> query. I pretty much just copied the code from the examples=20
> and modified it for my use, but I might have messed something=20
> up. The error I get when I run the program is:
> reference at ldap_test.pl line 95, <DATA> line 461.
> LDAP_CONTROL_PAGED ) or last;
> $searchRes->error . "\n";
> foreach() correctly, but it errors out when it hits line 95. =20
> Thanks in advance for any help you can provide.
>=20
>=20
> From Net::LDAP::Message:
>=20
> control ( OID, ... )
>=20
> Return a *list* of controls with the given OIDs that=20
> were returned=20
> from the server.
>=20
> So you want:
>=20
> my ($resp) =3D $searchRes->control( LDAP_CONTROL_PAGED ) or last;
>=20
> Then $resp will contain the first (and only) control, which=20
> is what you=20
> want. I got bit on the same problem, took more than a 1/2 hour to=20
> realize the problem.
>=20
>=20
|
|
|
|
|