Subject: | Restoring argspec on Connection->bind |
To reiterate on private correspondence, changes in the argument handling on Catalyst::Model::LDAP::Connection::bind() were interfering with the ability to bind with SASL using an empty DN (e.g. as one does with GSSAPI). The attached patch makes it possible to pass in dn => undef, as well as reinstates the original calling convention $ldap->bind($dn, %args).
Subject: | djt-catalyst-model-ldap-connection-bind.diff |
diff -ur Catalyst-Model-LDAP-0.21/lib/Catalyst/Model/LDAP/Connection.pm Catalyst-Model-LDAP-0.21-djt/lib/Catalyst/Model/LDAP/Connection.pm
--- Catalyst-Model-LDAP-0.21/lib/Catalyst/Model/LDAP/Connection.pm 2017-10-17 07:22:23.000000000 -0700
+++ Catalyst-Model-LDAP-0.21-djt/lib/Catalyst/Model/LDAP/Connection.pm 2019-09-09 16:19:26.400269618 -0700
@@ -39,7 +39,13 @@
sub bind {
- my ( $self, %args ) = @_;
+ my $self = shift;
+
+ # handle original Net::LDAP arg spec by assuming the first arg in
+ # an odd-numbered list is the DN
+ my %args;
+ $args{dn} = shift if @_ % 2;
+ %args = (%args, @_);
delete $args{$_} for qw/host base options connection_class entry_class/;
@@ -50,10 +56,11 @@
croak 'LDAP TLS error: ' . $mesg->error if $mesg->is_error;
}
- # Bind via DN if configured
- my $dn = delete $args{dn};
+ # Bind via DN if configured; use `exists` to account for empty DN
+ my $has_dn = exists $args{dn};
+ my $dn = delete $args{dn};
- $self->next::method( $dn ? ( $dn, %args ) : %args );
+ $self->next::method( $has_dn ? ( $dn, %args ) : %args );
}