[Rt-commit] rt branch, 4.4/ldapimport-connect-options, created. rt-4.4.2-102-gf356b1d9c
? sunnavy
sunnavy at bestpractical.com
Wed Mar 28 14:23:56 EDT 2018
The branch, 4.4/ldapimport-connect-options has been created
at f356b1d9c71483ce2bfebf15b3e286f7ebc76ced (commit)
- Log -----------------------------------------------------------------
commit 72630ddf9580cffbfeeb2c9c9f7006b183664299
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Wed May 3 17:05:13 2017 -0400
Provide a way to pass more options to Net::LDAP
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 6fe7bc7a2..412ced029 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2650,6 +2650,13 @@ available in the L<RT::LDAPImport> documentation.
Your LDAP server hostname.
+=item C<$LDAPOptions>
+
+This allows you to pass any options supported by the L<Net::LDAP> new method.
+e.g.
+
+ Set($LDAPOptions, [ port => 636 ]);
+
=item C<$LDAPUser>
The LDAP user to log in with.
diff --git a/lib/RT/LDAPImport.pm b/lib/RT/LDAPImport.pm
index bd731db88..9d469af4e 100644
--- a/lib/RT/LDAPImport.pm
+++ b/lib/RT/LDAPImport.pm
@@ -68,6 +68,7 @@ RT::LDAPImport - Import Users from an LDAP store
In C<RT_SiteConfig.pm>:
Set($LDAPHost,'my.ldap.host');
+ Set($LDAPOptions, [ port => 636 ]);
Set($LDAPUser,'me');
Set($LDAPPassword,'mypass');
Set($LDAPBase, 'ou=People,o=Our Place');
@@ -107,6 +108,11 @@ advanced options.
Hostname or ldap(s):// uri:
+=item C<< Set($LDAPOptions, [ port => 636 ]); >>
+
+This allows you to pass any options supported by the L<Net::LDAP>
+new method.
+
=item C<< Set($LDAPUser, 'uid=foo,ou=users,dc=example,dc=com'); >>
Your LDAP username or DN. If unset, we'll attempt an anonymous bind.
@@ -365,10 +371,11 @@ utility in openldap can be very helpful while refining your filters.
=head2 connect_ldap
-Relies on the config variables C<$LDAPHost>, C<$LDAPUser> and C<$LDAPPassword>
-being set in your RT Config files.
+Relies on the config variables C<$LDAPHost>, C<$LDAPOptions>, C<$LDAPUser>,
+and C<$LDAPPassword> being set in your RT Config files.
- Set($LDAPHost,'my.ldap.host')
+ Set($LDAPHost,'my.ldap.host');
+ Set($LDAPOptions, [ port => 636 ]);
Set($LDAPUSER,'me');
Set($LDAPPassword,'mypass');
@@ -382,7 +389,9 @@ LDAPHost can be a hostname or an ldap:// ldaps:// uri.
sub connect_ldap {
my $self = shift;
- my $ldap = Net::LDAP->new($RT::LDAPHost);
+ $RT::LDAPOptions = [] unless $RT::LDAPOptions;
+ my $ldap = Net::LDAP->new($RT::LDAPHost, @$RT::LDAPOptions);
+
$RT::Logger->debug("connecting to $RT::LDAPHost");
unless ($ldap) {
$RT::Logger->error("Can't connect to $RT::LDAPHost");
diff --git a/t/ldapimport/user-import.t b/t/ldapimport/user-import.t
index aafbd954d..4092a1c1c 100644
--- a/t/ldapimport/user-import.t
+++ b/t/ldapimport/user-import.t
@@ -43,6 +43,7 @@ $ldap->add(
RT->Config->Set('LDAPHost',"ldap://localhost:$ldap_port");
+RT->Config->Set('LDAPOptions', [ port => $ldap_port ]);
RT->Config->Set('LDAPMapping',
{Name => 'uid',
EmailAddress => 'mail',
commit f356b1d9c71483ce2bfebf15b3e286f7ebc76ced
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Fri Feb 2 17:01:18 2018 -0500
Provide more debug output on connect failure
diff --git a/lib/RT/LDAPImport.pm b/lib/RT/LDAPImport.pm
index 9d469af4e..ecfb17c38 100644
--- a/lib/RT/LDAPImport.pm
+++ b/lib/RT/LDAPImport.pm
@@ -394,7 +394,7 @@ sub connect_ldap {
$RT::Logger->debug("connecting to $RT::LDAPHost");
unless ($ldap) {
- $RT::Logger->error("Can't connect to $RT::LDAPHost");
+ $RT::Logger->error("Can't connect to $RT::LDAPHost $@");
return;
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list