turn warnings on
/usr/bin/perl -w
use strict;
use diagnostics;
On 5/22/06, beast <[EMAIL PROTECTED]> wrote:
I have these following code. It seems that sub is_exist never called more than
once.
I've checked ldap server log, the client never request for second search.
Putting $ldap object inside every sub will solve the problem, but doesn't it
expensive to create ldap connection object for every search?
---------
use strict;
use warnings;
use Net::LDAP;
....
my $ldap = Net::LDAP->new($ldap_host);
die "Unable to connect to $ldap_host\n" unless defined $ldap;
my $username = 'testing';
my $email = '[EMAIL PROTECTED]';
#check if username and email already used
my $unique = is_exist("uid=$username");
die "Username exists\n" if $unique;
$unique = is_exist("email=$email");
die "Email exists\n" if $unique;
sub is_exist {
my $ldap_filter = shift;
my ($res, $mesg);
$mesg = $ldap->bind;
$mesg = $ldap->search(
base => $ldap_base,
scope => 'one';
filter=> $ldap_filter;
attrs => ['uid'] );
$res = $mesg->count;
$mesg = $ldap->unbind;
return $res;
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>