From: Yann R. <at...@at...> - 2000-06-09 02:00:57
|
Ok, a followup on my bind question, I figured out the problem. There doesn't seem to be a way to have two simultaneous connections open. Take this code example: sub auth { my ($self, $uid, $passwd) = @_; my $uidsearch = "(&(objectclass=person)(uid=".$uid."))"; $mesg = $self->{LDAP}->search ( # perform a search base => $self->{ldap_config_base}, filter => $uidsearch ); my @result = $mesg->entries; my $entr = @result[0]; if (! defined $entr) { return 1; } my $entry = $entr->dn; $self->{LDAP}->unbind; undef $self->{LDAP}; $self->{AUTHLDAP} = Net::LDAP->new("192.168.0.41") or die "$@"; my $mesg = $self->{AUTHLDAP}->bind($entry, password => $passwd); print "And the result is...".$mesg->code."\n"; $self->{LDAP} = Net::LDAP->new("192.168.0.41") or die "$@"; $self->bind; # Bind as super user if ($mesg->code) { $self->{AUTHLDAP}->unbind; undef $self->{AUTHLDAP}; return 1; } $self->{AUTHLDAP}->unbind; undef $self->{AUTHLDAP}; return 0; } It works, only because LDAP is unbound and destroyed before AUTHLDAP is connected. Why? Yann -- -------------------------------------------------------------------- Yann Ramin at...@at... Atrus Trivalie Productions www.atrustrivalie.eu.org irm.it.montereyhigh.com Monterey High IT www.montereyhigh.com ICQ 46805627 AIM oddatrus Marina, CA "All cats die. Socrates is dead. Therefore Socrates is a cat." - The Logician # fortune "To be responsive at this time, though I will simply say, and therefore this is a repeat of what I said previously, that which I am unable to offer in response is based on information available to make no such statement." -------------------------------------------------------------------- |