[Rt-commit] rt branch, 4.4/ldapimport-connect-options, created. rt-4.4.1-334-g06a33a0

Jim Brandt jbrandt at bestpractical.com
Wed May 3 17:05:25 EDT 2017


The branch, 4.4/ldapimport-connect-options has been created
        at  06a33a0a0d4f78ffec4995a1356463ce3c3b14e5 (commit)

- Log -----------------------------------------------------------------
commit 06a33a0a0d4f78ffec4995a1356463ce3c3b14e5
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/lib/RT/LDAPImport.pm b/lib/RT/LDAPImport.pm
index bd731db..9d469af 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 c404bb5..a8c1fc6 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',

-----------------------------------------------------------------------


More information about the rt-commit mailing list