[Bps-public-commit] RT-Extension-LDAPImport branch, master, updated. 0.20_01-37-g2e0a4b1

Kevin Falcone falcone at bestpractical.com
Thu Jul 29 13:58:28 EDT 2010


The branch, master has been updated
       via  2e0a4b13e94588dfe0d699c8e42c2d6802866e09 (commit)
       via  24b6555b3fbaf14397578ed8274d19c424597d4a (commit)
      from  f63c1f3f18d879c5b0a5a6a850d76aa086ce7470 (commit)

Summary of changes:
 README                         |    2 ++
 lib/RT/Extension/LDAPImport.pm |   29 +++++++++++++++++++----------
 2 files changed, 21 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit 24b6555b3fbaf14397578ed8274d19c424597d4a
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Jul 29 14:00:02 2010 -0400

    tell people about autosetting description

diff --git a/README b/README
index 5a6f052..09f47bd 100644
--- a/README
+++ b/README
@@ -95,6 +95,8 @@ Attribute in RT => Attribute in LDAP
 The mapping logic is the same as the LDAPMapping.
 There is one important special-case variable, Member_Attr
 Use this to tell the importer which attribute will contain DNs of group members
+If you do not specify a Description attribute, it will be filled with
+'Imported from LDAP'
 
 RUNNING THE IMPORT
 

commit 2e0a4b13e94588dfe0d699c8e42c2d6802866e09
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Jul 29 14:00:11 2010 -0400

    here, have a dn->username cache

diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index 5e5711c..6ea2332 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -5,7 +5,7 @@ our $VERSION = '0.30_01';
 use warnings;
 use strict;
 use base qw(Class::Accessor);
-__PACKAGE__->mk_accessors(qw(_ldap _group screendebug));
+__PACKAGE__->mk_accessors(qw(_ldap _group screendebug _dnlist));
 use Carp;
 use Net::LDAP;
 use Data::Dumper;
@@ -192,6 +192,9 @@ sub _import_user {
     $self->_debug("Processing user $user->{Name}");
     my $user_obj = $self->create_rt_user( user => $user );
     return unless $user_obj;
+    my $dnlist = $self->_dnlist;
+    $dnlist->{$ldap_entry->dn} = $user->{Name};
+    $self->_dnlist($dnlist);
     $self->add_user_to_group( user => $user_obj );
     $self->add_custom_field_value( user => $user_obj, ldap_entry => $ldap_entry );
     return;
@@ -702,17 +705,23 @@ sub add_group_members {
         $rt_group_members->{$member->Name}++;
     }
 
+    my $dnlist = $self->_dnlist;
     foreach my $member (@$members) {
-        my $ldap_users = $self->_run_search(
-            base   => $member,
-            filter => $RT::LDAPFilter,
-        );
-        unless ( $ldap_users && $ldap_users->count ) {
-            $self->_error("No user found for $member who should be a member of $groupname");
-            next;
+        my $username;
+        if ($username = $dnlist->{$member}) {
+            $self->_debug("Found $username in cache for $member");
+        } else {
+            my $ldap_users = $self->_run_search(
+                base   => $member,
+                filter => $RT::LDAPFilter,
+            );
+            unless ( $ldap_users && $ldap_users->count ) {
+                $self->_error("No user found for $member who should be a member of $groupname");
+                next;
+            }
+            my $ldap_user = $ldap_users->shift_entry;
+            $username = $ldap_user->get_value($RT::LDAPMapping->{Name});
         }
-        my $ldap_user = $ldap_users->shift_entry;
-        my $username = $ldap_user->get_value($RT::LDAPMapping->{Name});
         if ( delete $rt_group_members->{$username} ) {
             $self->_debug("$username is already a member of $groupname skipping");
             next;

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



More information about the Bps-public-commit mailing list