Skip to content

Commit

Permalink
Allow caller to pass Authen::SASL client_new object
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarr committed Apr 24, 2009
1 parent 0f009c7 commit a92c4d4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
27 changes: 17 additions & 10 deletions lib/Net/LDAP.pm
Expand Up @@ -28,7 +28,7 @@ use Net::LDAP::Constant qw(LDAP_SUCCESS
LDAP_UNAVAILABLE
);

$VERSION = "0.39";
$VERSION = "0.39_01";
@ISA = qw(Tie::StdHash Net::LDAP::Extra);
$LDAP_VERSION = 3; # default LDAP protocol version

Expand Down Expand Up @@ -377,17 +377,24 @@ sub bind {
if $ldap->{net_ldap_version} < 3;

my $sasl = $passwd;
my $sasl_conn;

# If we're talking to a round-robin, the canonical name of
# the host we are talking to might not match the name we
# requested
my $connected_name = $ldap->{net_ldap_socket}->peerhost;
$connected_name ||= $ldap->{net_ldap_host};
if (ref($sasl) and $sasl->isa('Authen::SASL')) {

my $sasl_conn = eval {
local($SIG{__DIE__});
$sasl->client_new("ldap",$connected_name);
};
# If we're talking to a round-robin, the canonical name of
# the host we are talking to might not match the name we
# requested
my $connected_name = $ldap->{net_ldap_socket}->peerhost;
$connected_name ||= $ldap->{net_ldap_host};

$sasl_conn = eval {
local ($SIG{__DIE__});
$sasl->client_new("ldap", $connected_name);
};
}
else {
$sasl_conn = $sasl;
}

return _error($ldap, $mesg, LDAP_LOCAL_ERROR, "$@")
unless defined($sasl_conn);
Expand Down
9 changes: 8 additions & 1 deletion lib/Net/LDAP.pod
Expand Up @@ -298,7 +298,14 @@ Bind with the given password.
=item sasl =E<gt> SASLOBJ

Bind using a SASL mechanism. The argument given should be a sub-class
of L<Authen::SASL>.
of L<Authen::SASL> or an L<Authen::SASL> client connection by calling
C<client_new> on an L<Authen::SASL> object.

If passed an L<Authen::SASL> object then C<client_new> will be
called to create a client connection object. The hostname passed
by C<Net::LDAP> to C<client_new> is the result of calling C<peerhost>
on the socket. If this is not correct for your environment, consider
calling C<client_new> and passing the client connection object.

=back

Expand Down

0 comments on commit a92c4d4

Please sign in to comment.