From: Andrew T. <atr...@ac...> - 2000-11-30 06:56:39
|
I don't understand that while loop; why two calls to pop_entry()? Also, if I understand 'my' correctly, you won't have access to $entry outside the else block. Try something like this, my $entry; if ($mesg->code) { print $mesg->code." ".$mesg->error, "\n"; } else { $entry = $mesg->pop_entry(); } I have no idea how either of these things would cause pop_entry to hang, but give it a try. Best, Andrew -- On Nov 30, 6:21am, Graham Barr wrote: > Subject: Re: LDAP Search and pop_entry > I do seem to recall a bug in this part of the code in a previous release. > What version of Net::LDAP do you have installed ? > > Graham. > > On Wed, Nov 29, 2000 at 04:29:35PM -0900, Brian Avis wrote: > > Hello all, > > > > Having problems with ldap search and was hoping someone could help me > > out. > > > > I am writing a utility to let our admin staff add and remove a user from > > a group or a list of groups on the ldap server. > > > > So when the username is entered one of the first things I check is > > whether that user is in the LDAP server or not.... if they are then get > > their DN. > > > > This is the code in question. > > > > $mesg = $connection->search(base => $basedn, > > filter => "(uid=$uid)", > > timelimit => 10); > > > > > > if ($mesg->code) { > > print $mesg->code." ".$mesg->error; > > print "\n"; > > } else { > > > > my $entry; > > while ($entry = $mesg->pop_entry()) { > > > > $entry = $mesg->pop_entry(); > > > > } > > } > > > > if (!defined $entry) { > > print "\n$realname is not a valid user in the LDAP server\n"; > > redo; > > } > > > > my $userDN = $entry->dn(); > > > > > > The funny thing is that this was working for a couple of days but has > > quit working this afternoon. Go figure. Now though, when it gets to the > > $entry = $mesg->pop_entry(); line it hangs. The programs stops > > responding (and yes I waited a good long time for it to come back). When > > I looked up the pop_entry bit in the documentation this is all I found. > > > > pop_entry > > Pop an entry from the internal list of Net::LDAP::Entry > > objects for this search. If there are not more entries > > then undef is returned. > > > > This call will block, if the list is empty, until the > > server returns another entry. > > > > The last bit where it says this call will block if list is empty is > > probably what is causing me problems. > > > > So I guess the question is what is the best way to tell if a user exists > > in the LDAP server and if they do exists what is the best way to return > > their DN? > > > > Thanks in advance for the help. > > > > -- > > Brian Avis > > SEARHC Medical Clinic > > Juneau, AK 99801 > > (907) 463-4049 > > If nautical nonsense be something you wish. > > Then drop on the deck and flop like a fish. > > -- End of excerpt from Graham Barr -- -- and...@uc... Unix Systems Group, UC Riverside |