Subject: | Ldap version support |
this patch allows the ldap version to be specified in the config file,
it also incorporates the bind patch included in another ticket against
this cpan module.
if no ldap version is specified, the version defaults to the Net::LDAP
version (which is the current behavior)
including an LDAPVersion configuration parameter allows you to specify
the version => ?? value when Net::LDAP connects.
we have used this to connect to using LDAP2 for our users.
Subject: | djabberd-authen-ldap-version.patch |
*** DJabberd-Authen-LDAP-0.02/lib/DJabberd/Authen/LDAP.pm.orig 2007-08-24 05:12:08.000000000 +1000
--- DJabberd-Authen-LDAP-0.02/lib/DJabberd/Authen/LDAP.pm 2010-01-28 17:25:09.149259423 +1100
*************** our $VERSION = '0.02';
*** 35,40 ****
--- 35,41 ----
LDAPBindPW pass
LDAPBaseDN ou=people
LDAPFilter (&(inetAuthorizedServices=jabber)(uid=%u))
+ LDAPVersion 2
LDAPMethod rebind
</Plugin>
</VHost>
*************** LDAPFilter is an LDAP filter substutions
*** 50,55 ****
--- 51,59 ----
- %u will be substituted with the incoming userid (w/o the domain) (ie. myuser)
- %d will be substituted with the incoming userid's domain (ie. mydoman.com)
+ LDAPVersion is either 2 or 3, if nothing is specified then default to Net::LDAP default.
+ This value is passed straight to Net::LDAP
+
=head1 AUTHOR
Edward Rudd, C<< <urkle at outoforder.cc> >>
*************** sub set_config_ldapfilter {
*** 83,88 ****
--- 87,97 ----
$self->{'ldap_filter'} = $ldapfilter;
}
+ sub set_config_ldapversion {
+ my ($self, $ldapversion) = @_;
+ $self->{'ldap_version'} = $ldapversion;
+ }
+
sub set_config_ldapmethod {
my ($self, $ldapmethod) = @_;
if ( $ldapmethod =~ /^(?:rebind)$/ ) {
*************** sub finalize {
*** 96,103 ****
my $self = shift;
$logger->error_die("Invalid LDAP URI") unless $self->{ldap_uri};
$logger->error_die("No LDAP BaseDN Specified") unless $self->{ldap_basedn};
! if (not defined $self->{'ldap_method'}) { $self->{'ldap_type'} = 'rebind'; }
! for ($self->{ldap_type}) {
if (/^rebind$/) {
# check additional required params
$logger->error_die("Must specify filter with userid as %u") unless $self->{ldap_filter};
--- 105,112 ----
my $self = shift;
$logger->error_die("Invalid LDAP URI") unless $self->{ldap_uri};
$logger->error_die("No LDAP BaseDN Specified") unless $self->{ldap_basedn};
! if (not defined $self->{'ldap_method'}) { $self->{'ldap_method'} = 'rebind'; }
! for ($self->{ldap_method}) {
if (/^rebind$/) {
# check additional required params
$logger->error_die("Must specify filter with userid as %u") unless $self->{ldap_filter};
*************** sub finalize {
*** 105,112 ****
$logger->error_die("Invalid LDAP Authentication Method");
}
}
# Initialize ldap connection
! $self->{'ldap_conn'} = Net::LDAP->new($self->{ldap_uri})
or $logger->error_die("Could not connect to LDAP Server ".$self->{ldap_uri});
}
--- 114,125 ----
$logger->error_die("Invalid LDAP Authentication Method");
}
}
+
+ my %options;
+ $options{version} = $self->{ldap_version} if $self->{ldap_version};
+
# Initialize ldap connection
! $self->{'ldap_conn'} = Net::LDAP->new($self->{ldap_uri}, %options)
or $logger->error_die("Could not connect to LDAP Server ".$self->{ldap_uri});
}
*************** sub check_cleartext {
*** 131,137 ****
$cb->decline;
}
} else {
! $ldap->unbind;
}
my $filter = $self->{'ldap_filter'};
--- 144,150 ----
$cb->decline;
}
} else {
! $ldap->bind;
}
my $filter = $self->{'ldap_filter'};