From: Graham B. <gb...@po...> - 2002-01-30 15:59:00
|
I see two problems here, A bug in your code and a bug in Net::LDAP ->control returns a list, so calling it in a scalar context will simply return how many controls there were. You should also really pass the OID of the control you are looking for. But the bug in Net::LDAP is that it is not extracting controls from SearchResultEntry PDUs, but only SearchResultDone PDUs Simply adding $self->{controls} = $result->{controls} if exists $result->{controls}; at around line 38 in lib/Net/LDAP?Search.pm should solve that. However, this will only work for use in a callback, like you are doing. if someone just did the search then traversed the entry list, these controls would be lost. What is needed is for the Entry class to be able to hold controls, which is something that is needed for LDIF too. Graham. On Wed, Jan 30, 2002 at 10:14:00AM -0500, Marc Sherman wrote: > Hello, > > I'm trying to get persistent search working and I've been able to > successfully send the persistent search control to the server. When I make a > change on the server, it successfully sends me an entry change notification > control in response. I catch this response in the callback that I specified > to Net::LDAP->search() and I'm able to print out the DN of the changed > entry. My problem is that I am not able to extract the change notification > control in the response message. Here is the debug output which shows that > the control (OID 2.16.840.1.113730.3.4.7) is present in the response > message: > > Net::LDAP=HASH(0x1bdf0a8) received: > > 30 53 02 01 02 64 26 04 22 63 6E 3D 4C 75 63 79 0S...d&."cn=Lucy > 2C 6F 75 3D 44 65 76 65 6C 6F 70 6D 65 6E 74 2C ,ou=Development, > 6F 3D 42 69 6F 6E 65 74 72 69 78 30 00 A0 26 30 o=Bionetrix0..&0 > 24 04 17 32 2E 31 36 2E 38 34 30 2E 31 2E 31 31 $..2.16.840.1.11 > 33 37 33 30 2E 33 2E 34 2E 37 04 09 30 84 00 00 3730.3.4.7..0... > 00 03 0A 01 04 __ __ __ __ __ __ __ __ __ __ __ ..... > > 0000 83: SEQUENCE { > 0002 1: INTEGER = 2 > 0005 38: [APPLICATION 4] { > 0007 34: STRING = 'cn=Lucy,ou=Development,o=Bionetrix' > 002B 0: SEQUENCE { > 002D : } > 002D : } > 002D 38: [CONTEXT 0] { > 002F 36: SEQUENCE { > 0031 23: STRING = '2.16.840.1.113730.3.4.7' > 004A 9: STRING > 004C : 30 84 00 00 00 03 0A 01 04 __ __ __ __ __ __ __ 0........ > 0055 : } > 0055 : } > 0055 : } > In scrhCallBack !! > Got an entry !! > DN = cn=Lucy,ou=Development,o=Bionetrix > Died at D:\BAS\GenericSync\LDAP\test3.pl line 75. > > Here's my callback code: > > sub srchCallBack > { > my ($r, $obj) = @_; > print "In scrhCallBack !!\n"; > if (!$obj) > { > print "\t", $r->error, "\n"; > } > elsif ($obj->isa('Net::LDAP::Entry')) > { > print "\tGot an entry !!\n"; > print "\t\tDN = ", $obj->dn, "\n"; > $cbCtrl = $r->control or die "$@"; > print "\t\t", $cbCtrl, "\n"; > } > else > { > print "\tGot a reference !!\n"; > } > } > > As you can see my program dies as a result of $r->control failing. I tried > getting $r->code and $r->error but these methods cause the program to block > until the next change notification is received from the server. Any hints on > how to get the control? > > thanks, > Marc > > > > > > |