[Bps-public-commit] RT-Extension-LDAPImport branch, cli-base-arg, created. 0.36-6-g9b3d781

Shawn Moore shawn at bestpractical.com
Wed May 20 12:35:45 EDT 2015


The branch, cli-base-arg has been created
        at  9b3d781677c018f41418b4bb86b2485d363400a6 (commit)

- Log -----------------------------------------------------------------
commit 23c5cb6159be5fedd0147c0ca6753da4102e050e
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 20 16:21:10 2015 +0000

    Pass args down from import_users and run_user_search

diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index 3a3e984..15dfc69 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -420,11 +420,13 @@ Set up the appropriate arguments for a listing of users.
 
 sub run_user_search {
     my $self = shift;
+    my %args = @_;
+
     $self->_run_search(
         base   => $RT::LDAPBase,
-        filter => $RT::LDAPFilter
+        filter => $RT::LDAPFilter,
+        %args,
     );
-
 }
 
 =head2 _run_search
@@ -543,7 +545,7 @@ sub import_users {
 
     $self->_users({});
 
-    my @results = $self->run_user_search;
+    my @results = $self->run_user_search( %args );
     return $self->_import_users( %args, users => \@results );
 }
 

commit 718a08b3e61e53176330811166f7ba17acb10997
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 20 16:22:27 2015 +0000

    Factor out $ldap_base in add_group_members

diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index 15dfc69..b15b1de 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -1379,6 +1379,7 @@ sub add_group_members {
     my $group = $args{group};
     my $groupname = $args{name};
     my $ldap_entry = $args{ldap_entry};
+    my $ldap_base = $RT::LDAPBase;
 
     $self->_debug("Processing group membership for $groupname");
 
@@ -1409,7 +1410,7 @@ sub add_group_members {
             # I wonder if this will run into filter length limits? -trs, 22 Jan 2014
             my $members = join "", map { "($attr=" . escape_filter_value($_) . ")" } @$members;
             @entries = $self->_run_search(
-                base   => $RT::LDAPBase,
+                base   => $ldap_base,
                 filter => "(&$RT::LDAPFilter(|$members))",
             );
         }
@@ -1440,7 +1441,7 @@ sub add_group_members {
             next unless $username = $users->{lc $member};
         } else {
             my $attr    = lc($RT::LDAPGroupMapping->{Member_Attr_Value} || 'dn');
-            my $base    = $attr eq 'dn' ? $member : $RT::LDAPBase;
+            my $base    = $attr eq 'dn' ? $member : $ldap_base;
             my $scope   = $attr eq 'dn' ? 'base'  : 'sub';
             my $filter  = $attr eq 'dn'
                             ? $RT::LDAPFilter

commit d4fd88105172ccec9acb9e02b0c10e6eed571068
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 20 16:23:31 2015 +0000

    Support taking base as an arg in add_group_members

diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index b15b1de..1db4a9a 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -1379,7 +1379,7 @@ sub add_group_members {
     my $group = $args{group};
     my $groupname = $args{name};
     my $ldap_entry = $args{ldap_entry};
-    my $ldap_base = $RT::LDAPBase;
+    my $ldap_base = $args{base} || $RT::LDAPBase;
 
     $self->_debug("Processing group membership for $groupname");
 

commit fbc94575bce3805605ba9b7247acded49e5012d6
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 20 16:28:43 2015 +0000

    Make test import of users isomorphic to groups
    
        In other words, similar code should look similar :)

diff --git a/bin/rtldapimport.in b/bin/rtldapimport.in
index ef27f60..09b26fd 100755
--- a/bin/rtldapimport.in
+++ b/bin/rtldapimport.in
@@ -68,10 +68,16 @@ Running test import, no data will be changed
 Rerun command with --import to perform the import
 Rerun command with --debug for more information
 TESTING
-    $importer->import_users if $OPT{users};
+
+    if ($OPT{users}) {
+        print "Testing import\n";
+        $importer->import_users();
+    }
+
     if ($OPT{groups}) {
         print "Testing group import\n";
         $importer->import_groups();
     }
+
     print "Finished test\n";
 }

commit 9b3d781677c018f41418b4bb86b2485d363400a6
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Wed May 20 16:30:40 2015 +0000

    Let users pass --base to rtldapimport

diff --git a/bin/rtldapimport.in b/bin/rtldapimport.in
index 09b26fd..458401a 100755
--- a/bin/rtldapimport.in
+++ b/bin/rtldapimport.in
@@ -36,6 +36,7 @@ GetOptions(
     \%OPT,
     'debug', 'help',
     'import', 'users!', 'groups!',
+    'base=s',
 );
 if ($OPT{help}) {
    print <<USAGE;
@@ -43,23 +44,27 @@ $0: [--debug] [--import] [--help]
      --help           This usage statement.
      --debug          Enable debugging.
      --import         Do the import.
+     --base BASE      Use BASE in place of configured \$LDAPBase.
      --no-users       Skip users.
      --no-groups      Skip groups.
 USAGE
    exit 0;
 }
 
+my %args;
+$args{base} = $OPT{base} if $OPT{base};
+
 my $importer = RT::Extension::LDAPImport->new;
 $importer->screendebug(1) if $OPT{debug};
 
 if ($OPT{import}) {
     if ($OPT{users}) {
         print "Starting import\n";
-        $importer->import_users(import => 1);
+        $importer->import_users(%args, import => 1);
     }
     if ($OPT{groups}) {
         print "Starting group import\n";
-        $importer->import_groups(import => 1);
+        $importer->import_groups(%args, import => 1);
     }
     print "Finished import\n";
 } else {
@@ -71,12 +76,12 @@ TESTING
 
     if ($OPT{users}) {
         print "Testing import\n";
-        $importer->import_users();
+        $importer->import_users(%args);
     }
 
     if ($OPT{groups}) {
         print "Testing group import\n";
-        $importer->import_groups();
+        $importer->import_groups(%args);
     }
 
     print "Finished test\n";

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


More information about the Bps-public-commit mailing list